Skip to content

Commit 1f792fe

Browse files
yuhan0bbatsov
authored andcommitted
Prevent debugger from stepping through #_ ignored forms
1 parent 22f1406 commit 1f792fe

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cider-debug.el

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,17 @@ REASON is a keyword describing why this buffer was necessary."
505505
(search-forward-regexp (concat "\\_<" (regexp-quote key) "\\_>")
506506
limit 'noerror)))
507507

508+
(defun cider--debug-skip-ignored-forms ()
509+
"Skip past all forms ignored with #_ reader macro."
510+
;; Logic taken from `clojure--search-comment-macro-internal'
511+
(while (looking-at (concat "[ ,\r\t\n]*" clojure--comment-macro-regexp))
512+
(let ((md (match-data))
513+
(start (match-beginning 1)))
514+
(goto-char start)
515+
;; Count how many #_ we got and step by that many sexps
516+
(clojure-forward-logical-sexp
517+
(count-matches (rx "#_") (elt md 0) (elt md 1))))))
518+
508519
(defun cider--debug-move-point (coordinates)
509520
"Place point on after the sexp specified by COORDINATES.
510521
COORDINATES is a list of integers that specify how to navigate into the
@@ -579,7 +590,9 @@ key of a map, and it means \"go to the value associated with this key\"."
579590
(pop coordinates))))))
580591
;; If that extra pop was the last coordinate, this represents the
581592
;; entire #(...), so we should move back out.
582-
(backward-up-list))))
593+
(backward-up-list)))
594+
;; Finally skip past all #_ forms
595+
(cider--debug-skip-ignored-forms))
583596
;; Place point at the end of instrumented sexp.
584597
(clojure-forward-logical-sexp 1))
585598
;; Avoid throwing actual errors, since this happens on every breakpoint.

0 commit comments

Comments
 (0)