From 66fad123916924b42228487067eb155af830bef1 Mon Sep 17 00:00:00 2001 From: def Date: Wed, 9 Jul 2014 20:40:01 +0200 Subject: Change wordwrap to remove separators at newlines --- lib/pure/strutils.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index e642f6a99..51392ba50 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -535,7 +535,12 @@ proc wordWrap*(s: string, maxLineWidth = 80, ## word wraps `s`. result = newStringOfCap(s.len + s.len shr 6) var spaceLeft = maxLineWidth + var lastSep = "" for word, isSep in tokenize(s, seps): + if isSep: + lastSep = word + spaceLeft = spaceLeft - len(word) + continue if len(word) > spaceLeft: if splitLongWords and len(word) > maxLineWidth: result.add(substr(word, 0, spaceLeft-1)) @@ -554,7 +559,8 @@ proc wordWrap*(s: string, maxLineWidth = 80, result.add(word) else: spaceLeft = spaceLeft - len(word) - result.add(word) + result.add(lastSep & word) + lastSep.setLen(0) proc unindent*(s: string, eatAllIndent = false): string {. noSideEffect, rtl, extern: "nsuUnindent".} = -- cgit 1.4.1-2-gfad0 refs/?h=devel&id=f96d612e980af065217cddaf0a8521189977a37b'>refs log blame commit diff stats
path: root/contributors.txt
blob: e9909c677387576a1b296e6764c5f96abc680558 (plain) (tree)
1
2
3
4
5
6
7
8
9
     
                         
            
          
                        
               
               
                    
             
               


                 
>