Skip to content

Commit 5ee25ed

Browse files
committed
Use a single print-options variable to configure the debugger's
printing
1 parent c9dc922 commit 5ee25ed

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/cider/nrepl/middleware/debug.clj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ input requests. `read-debug-input` will halt until it finds its input in
175175
this map (identified by a key), and will `dissoc` it afterwards."}
176176
promises (atom {}))
177177

178-
(defonce print-length (atom nil))
179-
(defonce print-level (atom nil))
178+
(defonce print-options (atom nil))
180179
(defonce step-in-to-next? (atom false))
181180

182181
(defn pr-short
183182
"Like `pr-str` but limited in length and depth."
184183
[x]
185-
(binding [*print-length* @print-length
186-
*print-level* @print-level]
184+
(binding [*print-length* (:length @print-options)
185+
*print-level* (:level @print-options)]
186+
;; TODO: Make it possible to use a random print function here
187187
(pr-str x)))
188188

189189
(defn- locals-for-message
@@ -620,12 +620,11 @@ this map (identified by a key), and will `dissoc` it afterwards."}
620620

621621
(defn- initialize
622622
"Initialize the channel used for debug-input requests."
623-
[{:keys [print-length print-level] :as msg}]
623+
[{:keys [print-options] :as msg}]
624624
(when (map? @debugger-message)
625625
(debugger-send :status :done))
626626
;; The above is just bureaucracy. The below is important.
627-
(reset! @#'print-length print-length)
628-
(reset! @#'print-level print-level)
627+
(reset! @#'print-options print-options)
629628
(reset! debugger-message msg))
630629

631630
(defn- instrumented-defs-reply

test/clj/cider/nrepl/middleware/debug_test.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@
188188
2))))
189189

190190
(deftest pr-short-test
191-
(reset! d/print-length 4)
192-
(reset! d/print-level 2)
191+
(reset! d/print-options {:length 4, :level 2})
193192
(is (< (count (d/pr-short [1 2 3 4 5 6 7 8 9 10]))
194193
(count (pr-str [1 2 3 4 5 6 7 8 9 10]))))
195194
(is (< (count (d/pr-short [[[1 2 3 4]]]))

0 commit comments

Comments
 (0)