diff --git a/CHANGELOG.md b/CHANGELOG.md index 09bc6b291..30d7172ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cider-eval.el b/cider-eval.el index 110505bd8..3d157c711 100644 --- a/cider-eval.el +++ b/cider-eval.el @@ -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.