1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

Fix pretty-print with a per-line prefix

* module/ice-9/pretty-print.scm (pretty-print): Include the per-line
prefix in the indent.
* test-suite/tests/print.test ("pretty-print"): Add test.
This commit is contained in:
Andy Wingo 2023-11-15 09:35:23 +01:00
parent 75cd95060f
commit 437e5ac43d
2 changed files with 19 additions and 2 deletions

View file

@ -114,7 +114,7 @@ port directly after OBJ, like (pretty-print OBJ PORT)."
((< to col)
(put-string port "\n")
(put-string port per-line-prefix)
(spaces to))
(spaces (- to (string-length per-line-prefix))))
(else
(spaces (- to col))))))

View file

@ -127,7 +127,24 @@
" (1\n"
" (0\n"
" 0))))))))))\n")
#:width 10)))
#:width 10))
(pass-if "prefix"
(prints? (9 (8 (7 (6 (5 (4 (3 (2 (1 (0 0))))))))))
(string-append
"> (9\n"
"> (8\n"
"> (7\n"
"> (6\n"
"> (5\n"
"> (4\n"
"> (3\n"
"> (2\n"
"> (1\n"
"> (0\n"
"> 0))))))))))\n")
#:width 10
#:per-line-prefix "> ")))
(with-test-prefix "truncated-print"