diff --git a/lib/event_ds.dart b/lib/event_ds.dart index 0aa7c16..e86aa12 100644 --- a/lib/event_ds.dart +++ b/lib/event_ds.dart @@ -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; } } diff --git a/pubspec.yaml b/pubspec.yaml index 568b958..09e261a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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' diff --git a/test/nostr_console_test.dart b/test/nostr_console_test.dart index 908cf67..9f0bf47 100644 --- a/test/nostr_console_test.dart +++ b/test/nostr_console_test.dart @@ -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