fixed how word is broken at non-space char

This commit is contained in:
Vishal 2022-09-15 14:25:17 +05:30
parent ecca05e771
commit 7650efbc0c
3 changed files with 31 additions and 3 deletions

View File

@ -833,6 +833,8 @@ String makeParagraphAtDepth(String s, int depthInSpaces) {
String line = listCulledLine[0];
int lenReturned = listCulledLine[1] as int;
//print("In makeParagraphAtDepth: line len = ${line.length} lenReturned = $lenReturned");
if( line.length == 0 || lenReturned == 0) break;
newString += line;
@ -886,8 +888,12 @@ List getLineWithMaxLen(String s, int startIndex, int lenPerLine, String spacesSt
// break the line here if its not a word separator
if( isWordSeparater(line[i])) {
//print(" isWordSeparater i = $i line[i] = ${line[i]}");
firstLineLen = i;
line = line.substring(0, i) + "\n" + spacesString + line.substring(i + 1, line.length);
int newLineStart = i + 1;
if( line[i] != ' ')
newLineStart = i;
line = line.substring(0, i) + "\n" + spacesString + line.substring(newLineStart, line.length);
lineBroken = true;
}
}

View File

@ -4,7 +4,7 @@ version: 0.0.7-beta
homepage: https://github.com/vishalxl/nostr_console
# Release 0.0.7-beta
# Release 0.0.7-beta fixed how word is broken at non-space char
environment:
sdk: '>=2.17.3 <3.0.0'

View File

@ -148,7 +148,7 @@ String expectedResult =
stdout.write("\n");
stdout.write(getNumDashes(30));
//stdout.write(getNumSpaces(30)); */
stdout.write(res);
//stdout.write(res);
//return res == expectedResult;;
expect( res, expectedResult);
@ -194,5 +194,27 @@ String expectedResult =
expect( res, expectedResult);
});
test('break_url_dash ', () {
gTextWidth = 92;
//print("\n\nbreak_url_dash test");
String paragraph = """
https://github.com/vishalxl/nostr_console/releases/tag/v0.0.7-beta""";
String expectedResult =
"""https://github.com/vishalxl/nostr_console/releases/tag/v0.0.7
-beta""";
String res = makeParagraphAtDepth(paragraph, 30);
//print(res);
expect( res, expectedResult);
});
return ;
} // end main