[ 
https://issues.apache.org/jira/browse/KARAF-7678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17701304#comment-17701304
 ] 

ASF GitHub Bot commented on KARAF-7678:
---------------------------------------

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.





> ShellTable erroneously clips out text from multi-line column contents
> ---------------------------------------------------------------------
>
>                 Key: KARAF-7678
>                 URL: https://issues.apache.org/jira/browse/KARAF-7678
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>    Affects Versions: 4.4.3
>            Reporter: Ciprian Ciubotariu
>            Priority: Minor
>
> The {{ShellTable}} implementation clips column contents to the column's 
> {{maxSize}} before inspecting if the contents is sigle or multi-line. This 
> idea works well with single-line row contents, but it is faulty if the column 
> text contains newlines.
> Given that the newline split is already implemented for the text wrapping 
> function, there is an opportunity for the user to pass multi-line table 
> contents.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to