You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by "wborn (via GitHub)" <gi...@apache.org> on 2023/03/16 16:58:17 UTC

[GitHub] [karaf] wborn commented on a diff in pull request #1716: [KARAF-7678] Fix ShellTable multiline clipping

wborn commented on code in PR #1716:
URL: https://github.com/apache/karaf/pull/1716#discussion_r1139062134


##########
shell/core/src/main/java/org/apache/karaf/shell/support/table/Col.java:
##########
@@ -148,8 +149,14 @@ String format(Object cellData) {
         if (fullContent.length() == 0) {
             return "";
         }
-        String finalContent = cut(fullContent, getClippedSize(fullContent.length()));
-        updateSize(finalContent.length());
+        if (wrap && size < fullContent.length()) {
+            // make sure splitLines will have an estimate cell size if wrap is true
+            updateSize(fullContent.length());
+        }
+        List<String> lines = splitLines(fullContent);
+        int maxLineSize = lines.stream().mapToInt(String::length).max().getAsInt(); // at least one line exists due to test above
+        updateSize(maxLineSize); // calls getClippedSize()
+        String finalContent = lines.stream().map(line -> cut(line, getClippedSize(line.length()))).collect(Collectors.joining("\n"));

Review Comment:
   Will this work on Windows which uses a different line separator?
   E.g. using `System.lineSeparator()` would be based on the OS.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org