fix(cli): preserve deep preview values

This commit is contained in:
rcmerci
2026-05-17 17:56:23 +08:00
parent d3823805e7
commit c673ff428c
2 changed files with 9 additions and 2 deletions

View File

@@ -8,8 +8,7 @@
(defn- bounded-pr-str
[value limit]
(binding [*print-length* (inc limit)
*print-level* 4]
(binding [*print-length* (inc limit)]
(pr-str value)))
(defn truncate-preview

View File

@@ -31,6 +31,14 @@
(is (= "nil" (:preview result)))
(is (false? (:truncated? result)))))
(testing "preserves deep values when the preview limit is large enough"
(let [value {:a {:b {:c {:d {:e 1}}}}}
expected (pr-str value)
result (cli-log/truncate-preview value 1000)]
(is (= expected (:preview result)))
(is (= (count expected) (:length result)))
(is (false? (:truncated? result)))))
(testing "does not realize a full lazy collection for a short preview"
(let [realized (atom 0)
value (map (fn [n]