Skip to content

Commit c5f3084

Browse files
committed
Form tagged with #break is always interesting
1 parent cbbee76 commit c5f3084

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/cider/nrepl/middleware/debug.clj

+22-17
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ this map (identified by a key), and will `dissoc` it afterwards."}
494494
{:style/indent 1}
495495
[form dbg-state original-form]
496496
`(with-initial-debug-bindings
497-
(breakpoint-if-interesting
497+
(breakpoint
498498
~form ~dbg-state ~original-form)))
499499

500500
(defmacro breakpoint-if-exception-with-initial-debug-bindings
@@ -571,29 +571,34 @@ this map (identified by a key), and will `dissoc` it afterwards."}
571571
(and (seq? form)
572572
(irrelevant-return-value-forms (first form)))))
573573

574+
(defmacro breakpoint
575+
"Wrap form in a breakpoint unconditionally."
576+
[form {:keys [coor] :as dbg-state} original-form]
577+
(let [condition (:break/when (meta form))]
578+
(if condition
579+
;; If there is a condition and it is falsy, we need to skip
580+
;; the current level (:deeper than parent coor), but only
581+
;; once. Next time, we need to test the condition again.
582+
`(let [old-breaks# @*skip-breaks*]
583+
(when-not ~condition
584+
(skip-breaks! :deeper ~(vec (butlast coor)) (:code (:msg ~'STATE__)) false))
585+
(try
586+
(expand-break ~form ~dbg-state ~original-form)
587+
;; in case :continue-all was requested in a deeper level
588+
;; we don't want go back to the old-breaks
589+
(finally (when (not= :all (:mode @*skip-breaks*))
590+
(reset! *skip-breaks* old-breaks#)))))
591+
`(expand-break ~form ~dbg-state ~original-form))))
592+
574593
(defmacro breakpoint-if-interesting
575594
"Wrap form in a breakpoint if it looks interesting.
576595
Uninteresting forms are symbols that resolve to `clojure.core`
577596
(taking locals into account), and sexps whose head is present in
578597
`irrelevant-return-value-forms`. Used as :breakfunction in `tag-form`."
579-
[form {:keys [coor] :as dbg-state} original-form]
598+
[form dbg-state original-form]
580599
(if (uninteresting-form? &env form)
581600
form
582-
(let [condition (:break/when (meta form))]
583-
(if condition
584-
;; If there is a condition and it is falsy, we need to skip
585-
;; the current level (:deeper than parent coor), but only
586-
;; once. Next time, we need to test the condition again.
587-
`(let [old-breaks# @*skip-breaks*]
588-
(when-not ~condition
589-
(skip-breaks! :deeper ~(vec (butlast coor)) (:code (:msg ~'STATE__)) false))
590-
(try
591-
(expand-break ~form ~dbg-state ~original-form)
592-
;; in case :continue-all was requested in a deeper level
593-
;; we don't want go back to the old-breaks
594-
(finally (when (not= :all (:mode @*skip-breaks*))
595-
(reset! *skip-breaks* old-breaks#)))))
596-
`(expand-break ~form ~dbg-state ~original-form)))))
601+
`(breakpoint ~form ~dbg-state ~original-form)))
597602

598603
(defmacro breakpoint-if-exception
599604
"Wrap form in a try-catch that has breakpoint on exception.

0 commit comments

Comments
 (0)