@@ -772,9 +772,9 @@ list[tuple[str, str]] separateLines(str input, list[str] lineseps = newLineChara
772772
773773 list [tuple [str , str ]] lines = [];
774774 int next = 0 ;
775- for (int i <- [0 ..size (input )]) {
775+ for (int i <- [0 ..size (input )], i > = next ) {
776776 // greedily match line separators (longest first)
777- if (i > = next , str nl <- orderedSeps , nl == input [i ..i +size (nl )]) {
777+ if (str nl <- orderedSeps , nl == input [i ..i +size (nl )]) {
778778 lines += <input [next ..i ], nl > ;
779779 next = i + size (nl ); // skip to the start of the next line
780780 }
@@ -797,9 +797,9 @@ str perLine(str input, str(str) lineFunc, list[str] lineseps = newLineCharacters
797797 = mergeLines ([<lineFunc (l ), nl > | <l , nl > <- separateLines (input , lineseps =lineseps )]);
798798
799799@synopsis {Trim trailing non-newline whitespace from each line in a multi-line string.}
800- str trimTrailingWhitespace (str input ) {
800+ str trimTrailingWhitespace (str input , list [ str ] lineseps = newLineCharacters ) {
801801 str trimLineTrailingWs (/^<nonWhiteSpace :.*\S > \s *$/) = nonWhiteSpace ;
802802 default str trimLineTrailingWs (/^\s *$/) = "" ;
803803
804- return perLine (input , trimLineTrailingWs );
804+ return perLine (input , trimLineTrailingWs , lineseps = lineseps );
805805}
0 commit comments