Skip to content

Commit 0c83f55

Browse files
committed
Allow wrapping of non-list colls in breakpoints
1 parent 8193eb9 commit 0c83f55

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/cider/nrepl/middleware/debug.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ this map (identified by a key), and will `dissoc` it afterwards."}
620620
(defn breakpoint-reader
621621
"#break reader. Mark `form` for breakpointing."
622622
[form]
623-
(ins/tag-form form #'breakpoint-with-initial-debug-bindings))
623+
(ins/tag-form form #'breakpoint-with-initial-debug-bindings true))
624624

625625
(defn debug-reader
626626
"#dbg reader. Mark all forms in `form` for breakpointing.
@@ -632,7 +632,7 @@ this map (identified by a key), and will `dissoc` it afterwards."}
632632
(defn break-on-exception-reader
633633
"#exn reader. Wrap `form` in try-catch and break only on exception"
634634
[form]
635-
(ins/tag-form form #'breakpoint-if-exception-with-initial-debug-bindings))
635+
(ins/tag-form form #'breakpoint-if-exception-with-initial-debug-bindings true))
636636

637637
(defn debug-on-exception-reader
638638
"#dbgexn reader. Mark all forms in `form` for breakpointing on exception.

src/cider/nrepl/middleware/util/instrument.clj

+12-5
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,11 @@
225225
;; Other coll types are safe, so we go inside them and only
226226
;; instrument what's interesting.
227227
;; Do we also need to check for seq?
228-
coll? (doall (instrument-coll form))
228+
coll? (cond-> (doall (instrument-coll form))
229+
(::do-break (meta form)) (with-break))
229230
;; Other things are uninteresting, literals or unreadable objects.
230-
form))
231+
(cond-> form
232+
(::do-break (meta form)) (with-break))))
231233

232234
;;;; ## Pre-instrumentation
233235
;;;
@@ -294,9 +296,14 @@
294296
"Tag form to be instrumented with breakfunction.
295297
This sets the ::breakfunction metadata of form, which can then be
296298
used by `instrument-tagged-code`. See this function for the meaning
297-
of breakfunction."
298-
[form breakfunction]
299-
(m/merge-meta form {::breakfunction breakfunction}))
299+
of breakfunction.
300+
When `do-break?` is true it tells the instrumenter to wrap the form
301+
with a breakpoint regardless of other heuristics."
302+
([form breakfunction]
303+
(tag-form form breakfunction false))
304+
([form breakfunction do-break?]
305+
(m/merge-meta form {::breakfunction breakfunction}
306+
(when do-break? {::do-break true}))))
300307

301308
(defn tag-form-recursively
302309
"Like `tag-form` but also tag all forms inside the given form."

0 commit comments

Comments
 (0)