Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit df2f6ca

Browse files
committedJun 15, 2023
Allow wrapping of non-list colls in breakpoints
1 parent 297b2cc commit df2f6ca

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
@@ -627,7 +627,7 @@ this map (identified by a key), and will `dissoc` it afterwards."}
627627
(defn breakpoint-reader
628628
"#break reader. Mark `form` for breakpointing."
629629
[form]
630-
(ins/tag-form form #'breakpoint-with-initial-debug-bindings))
630+
(ins/tag-form form #'breakpoint-with-initial-debug-bindings true))
631631

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

644644
(defn debug-on-exception-reader
645645
"#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)
Please sign in to comment.