From 0424d2e351c05dc279cb9292c035611dc104ecda Mon Sep 17 00:00:00 2001
From: Peter Streef
Date: Mon, 22 Apr 2024 17:35:59 +0200
Subject: [PATCH] Count last line if not empty
---
src/main/java/org/openrewrite/LanguageComposition.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/main/java/org/openrewrite/LanguageComposition.java b/src/main/java/org/openrewrite/LanguageComposition.java
index 2c5b585..7d8d983 100644
--- a/src/main/java/org/openrewrite/LanguageComposition.java
+++ b/src/main/java/org/openrewrite/LanguageComposition.java
@@ -392,6 +392,12 @@ public PrintOutputCapture append(@Nullable String text) {
count++;
}
}
+ if(!text.isEmpty()) {
+ char last = text.charAt(text.length() - 1);
+ if (last != '\n' && last != '\r') {
+ count++;
+ }
+ }
return this;
}