]> gitweb.factorcode.org Git - factor.git/commitdiff
wrap.strings: empty strings should wrap as the indent.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 5 Aug 2013 18:25:01 +0000 (11:25 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 5 Aug 2013 18:25:01 +0000 (11:25 -0700)
basis/wrap/strings/strings-tests.factor
basis/wrap/strings/strings.factor

index 181090c4093dbd9efb84a9a6c963425b899337b2..9eab9ca72509c884195a69fb715664be4b79f693 100644 (file)
@@ -47,3 +47,5 @@ word wrap."""
 
 [ "" ] [ "" 10 wrap-string ] unit-test
 [ "Hello" ] [ "\nHello\n" 10 wrap-string ] unit-test
+
+{ " > > > " } [ "" 70 " > > > " wrap-indented-string ] unit-test
index 0825edcc4bdbfb8cf88f3dc91e4633224c6fc797..ed3fc3967e16da6922c9885d90c86e9990ce3dbb 100644 (file)
@@ -34,4 +34,4 @@ PRIVATE>
 
 : wrap-indented-string ( string width indent -- newstring )
     make-indent [ length - wrap-lines ] keep
-    '[ _ prepend ] map! join-lines ;
+    over empty? [ nip ] [ '[ _ prepend ] map! join-lines ] if ;