-
-
Notifications
You must be signed in to change notification settings - Fork 648
Description
Expected behavior
Executing cider-debug-defun-at-point (C-u C-M-x) should work in source for forms in an indented comment block when clojure-toplevel-inside-comment-form
is true.
(comment
(inc (inc 0))
)
More generally, this occurs when evaluating any indented form tagged with #dbg
(do
#dbg (str (inc 0)) ;; cider-eval-last-sexp here
...)
Actual behavior
The source "cannot be found" and a temporary debug buffer is created.
Steps to reproduce the problem
place cursor at | and eval last sexp
(do
#dbg (str (inc 0)) |
...)
Solution
After some detective work I found the underlying issue to be the difference in column indexing between Emacs (0-indexed) and Clojure (1-indexed).
The outgoing conversion to 1-indexing happens in cider-interactive-eval
, using the function cider-column-number-at-pos
, so nrepl messages are sent as 1-indexed columns.
Line 757 in 1911c47
(defun cider-column-number-at-pos (pos) |
However for incoming responses, this line in cider-nrepl causes only toplevel forms (column = 1) to be converted to 0-indexing , and no further processing is done client-side.
clojure-emacs/cider-nrepl@7660eb7#diff-0d65c570bef3dbf4640690a252e06f28R340
When column != 1 this causes an off-by-one error and the cider-debug code thinks the source has been edited.
I think the proper solution to this would be to remove the above line in cider-nrepl and offset the 1-indexed response in Emacs. This may break other clients, in particular Calva.
Environment & Version information
CIDER version information
;; CIDER 0.25.0snapshot, nREPL 0.7.0
;; Clojure 1.10.1, Java 14.0.1
Emacs version
26.3
Operating system
macOS 10.14