]> gitweb.factorcode.org Git - factor.git/commitdiff
prettyprint: Don't print ~1 more~ when there is only one element left. Fixes #524.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 20 Mar 2013 21:26:05 +0000 (14:26 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 20 Mar 2013 21:26:05 +0000 (14:26 -0700)
basis/prettyprint/backend/backend.factor
basis/prettyprint/prettyprint-tests.factor

index 1d03707e6718c16e9013f004fe936d68615c508c..fc3c66de9f84c9c2fd135df775869778618315ed 100644 (file)
@@ -197,7 +197,7 @@ M: tuple pprint*
 : do-length-limit ( seq -- trimmed n/f )
     length-limit get dup [
         over length over [-]
-        [ drop f ] [ [ head-slice ] dip ] if-zero
+        dup 1 > [ [ head-slice ] dip ] [ 2drop f ] if
     ] when ;
 
 : pprint-elements ( seq -- )
index 17cedcc7e499a7cf105946dd1b54fed4092f01fa..471fba702627afb40cd9efc95696bd08adba2d49 100644 (file)
@@ -465,7 +465,12 @@ TUPLE: fo { a intersection{ integer fixnum } initial: 0 } ;
     with-string-writer
 ] unit-test
 
-{ "{ 0 1 2 3 4 ~1 more~ }" } [
+{ "{ 0 1 2 3 4 5 }" } [
     [ 5 length-limit [ 6 iota >array pprint ] with-variable ]
     with-string-writer
 ] unit-test
+
+{ "{ 0 1 2 3 4 ~2 more~ }" } [
+    [ 5 length-limit [ 7 iota >array pprint ] with-variable ]
+    with-string-writer
+] unit-test