Skip to content

Commit

Permalink
ensure truncation works the same on windows and linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Luro02 committed Apr 13, 2024
1 parent 320a2aa commit 86c1b11
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,14 @@ public static String truncatedSuggestion(CtElement ctElement) {
StringJoiner result = new StringJoiner(System.lineSeparator());

for (String line : ctElement.toString().split("\\r?\\n")) {
if (result.length() > 150) {
int newLineLength = 0;

// this ensures that the truncation is the same on linux and windows
if (!result.toString().contains("\r\n")) {
newLineLength += (int) result.toString().chars().filter(ch -> ch == '\n').count();
}

if (result.length() + newLineLength > 150) {
if (line.startsWith(" ")) {
result.add("...".indent(line.length() - line.stripIndent().length()).stripTrailing());
} else {
Expand Down

0 comments on commit 86c1b11

Please sign in to comment.