diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 201a1c28d2..9352673a61 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -226,9 +226,13 @@ M: object pprint-object ( obj -- ) M: object pprint* pprint-object ; M: vector pprint* pprint-object ; M: byte-vector pprint* pprint-object ; + +: with-extra-nesting-level ( quot -- ) + nesting-limit [ dup [ 1 + ] [ f ] if* ] change + [ nesting-limit set ] curry [ ] cleanup ; inline + M: hashtable pprint* - nesting-limit inc - [ pprint-object ] [ nesting-limit dec ] [ ] cleanup ; + [ pprint-object ] with-extra-nesting-level ; M: curry pprint* pprint-object ; M: compose pprint* pprint-object ; M: hash-set pprint* pprint-object ; diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index ec0e20a393..42a7322037 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -374,3 +374,16 @@ TUPLE: final-tuple ; final ] [ [ \ final-tuple see ] with-string-writer "\n" split ] unit-test + +[ "H{ { 1 2 } }\n" ] [ [ H{ { 1 2 } } short. ] with-string-writer ] unit-test + +[ "H{ { 1 ~array~ } }\n" ] [ [ H{ { 1 { 2 } } } short. ] with-string-writer ] unit-test + +[ "{ ~array~ }\n" ] [ [ { { 1 2 } } short. ] with-string-writer ] unit-test + +[ "H{ { 1 { 2 3 } } }\n" ] [ + f nesting-limit [ + [ H{ { 1 { 2 3 } } } . ] with-string-writer + ] with-variable +] unit-test +