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

Gary D. Gregory edited comment on TEXT-231 at 9/10/23 5:11 PM:
---------------------------------------------------------------

No. Don't edit changes.xml as it will likely conflict with anyone else who does 
so as well.

You can pick the branch name.

In general, keep your changes to a minimum, IOW don't "reorganize" code for 
cosmetic or arbitrary reasons, it just takes longer to review.


was (Author: garydgregory):
No. Don't edit changes.xml as it will likely conflict with anyone else who does 
so as well.

You can pick the branch name.

> WordUtils.wrap should react to prexisting "new line string" as a wrap
> ---------------------------------------------------------------------
>
>                 Key: TEXT-231
>                 URL: https://issues.apache.org/jira/browse/TEXT-231
>             Project: Commons Text
>          Issue Type: Improvement
>    Affects Versions: 1.10.0
>            Reporter: Michael Karnerfors
>            Priority: Minor
>         Attachments: TEXT-231-wrap-on-newline-string.patch
>
>
> WordUtils.wrap ignores pre-existing occurrences of the "new line string" and 
> counts them as part of a line, instead of as a wrap.
> Example: 
> {code:java}
> public static final String LINE_SEPARATOR = "\n"; 
> void wrap() {
>     String line = "Alpha"+ LINE_SEPARATOR + "Bravo Charlie Delta Echo 
> Foxtrot";
>     System.out.println(WordUtils.wrap(line, 13));
> } {code}
> The default new line string is just newline ("\n"). So in this case I would 
> expect this to output...
> {noformat}
> Alpha
> Bravo Charlie
> Delta Echo 
> Foxtrot
> {noformat}
> However, since WordUtils.wrap does not consider the pre-existing newline 
> after "Alpha" as one of its own wraps, I instead get...
> {noformat}
> Alpha
> Bravo
> Charlie Delta
> Echo Foxtrot
> {noformat}
> There is a work-around, but it is not as elegant...
> {code:java}
> String wrappedLine = 
>     Arrays
>         .stream(
>             line.split(LINE_SEPARATOR)
>         )
>         .map(
>             subLine -> WordUtils.wrap(subLine, 13)
>         )
>         .collect(
>             Collectors.joining(LINE_SEPARATOR)
>         );
> System.out.println(wrappedLine);
> {code}
> Hence, I suggest that WordUtils.wrap should consider matches of "newLineStr" 
> as a wrap, and any directly following text as the beginning of the next line. 



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

Reply via email to