Skip to content

Commit

Permalink
cider-eval: never jump to spurious locations
Browse files Browse the repository at this point in the history
  • Loading branch information
vemv committed Jul 26, 2023
1 parent cc31f5b commit b4fec3c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [#3355](https://github.com/clojure-emacs/cider/pull/3355): Fix `cider-mode` disabling itself after a disconnect when `cider-auto-mode` is set to nil.
- [#3362](https://github.com/clojure-emacs/cider/issues/3362): Fix `sesman-restart` regression issue.
- [#3236](https://github.com/clojure-emacs/cider/issues/3236): `cider-repl-set-ns` no longer changes the repl session type from `cljs:shadow` to `clj`.
- [#3331](https://github.com/clojure-emacs/cider/issues/3331): `cider-eval`: never jump to spurious locations, as sometimes conveyed by nREPL.

### Changes

Expand Down
19 changes: 13 additions & 6 deletions cider-eval.el
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,19 @@ If location could not be found, return nil."
(widen)
(goto-char (point-min))
(forward-line (1- line))
(move-to-column (or col 0))
(let ((begin (progn (if col (cider--goto-expression-start) (back-to-indentation))
(point)))
(end (progn (if col (forward-list) (move-end-of-line nil))
(point))))
(list begin end buffer))))))))))))
(move-to-column col)
;; if this condition is true, it means that `col` was a spuriously large value,
;; therefore the whole calculation should be discarded:
(when (or (not col) ;; if there's no col info, we cannot judge if it's spurious/not
;; (current-column) never goes past the last column in the actual file,
;; so if it's <, then the message had spurious info:
(= (+ 1 (current-column))
col))
(let ((begin (progn (if col (cider--goto-expression-start) (back-to-indentation))
(point)))
(end (progn (if col (forward-list) (move-end-of-line nil))
(point))))
(list begin end buffer)))))))))))))

(defun cider-handle-compilation-errors (message eval-buffer)
"Highlight and jump to compilation error extracted from MESSAGE.
Expand Down

0 comments on commit b4fec3c

Please sign in to comment.