Skip to content

Commit cc1011c

Browse files
committed
Merge pull request #1325 from turbopape/master
[Fix #715] Add jump to error location when clicking on error message
2 parents a3afb47 + 5721c14 commit cc1011c

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## master (unreleased)
44

55
### New features
6-
6+
* [#1325](https://github.com/clojure-emacs/cider/issues/1325): Jump to error location when clicking on the error message in the stack-trace pop-up.
77
* [#1301](https://github.com/clojure-emacs/cider/issues/1301): CIDER can do dynamic font-locking of defined variables, functions, and macros. This is controlled by the `cider-font-lock-dynamically` custom option.
88
* [#1271](https://github.com/clojure-emacs/cider/issues/1271): New possible value (`always-save`) for `cider-prompt-save-file-on-load`.
99
* [#1197](https://github.com/clojure-emacs/cider/issues/1197): Display some indication that we're waiting for a result for long-running evaluations.

cider-stacktrace.el

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,26 @@ This associates text properties to enable filtering and source navigation."
502502
(put-text-property p2 p3 'font-lock-face 'cider-stacktrace-fn-face)))
503503
(newline)))))
504504

505+
(defun cider-stacktrace--create-go-to-err-button (beg message)
506+
"Create a button that jumps to the relevant error.
507+
508+
Buttons span over the region from BEG to current point.
509+
MESSAGE is parsed to find line, col and buffer name to jump to."
510+
(when (string-match "\\([^:]+\\):\\([^:]+\\):\\([^:]+\\):\\([^:]+\\)\\'" message)
511+
(let* ((line (string-to-number (match-string 3 message)))
512+
(col (string-to-number (match-string 4 message)))
513+
(buf-name (car (last (split-string (match-string 2 message) "\\/")))))
514+
(when buf-name
515+
(make-button (+ beg 3)
516+
(point)
517+
'action (lambda (button)
518+
(let ((the-buf-window (get-buffer-window buf-name)))
519+
(if the-buf-window
520+
(select-window the-buf-window)
521+
(switch-to-buffer buf-name)))
522+
(goto-line line)
523+
(move-to-column col t)))))))
524+
505525
(defun cider-stacktrace-render-cause (buffer cause num note)
506526
"Emit into BUFFER the CAUSE NUM, exception class, message, data, and NOTE."
507527
(with-current-buffer buffer
@@ -518,8 +538,10 @@ This associates text properties to enable filtering and source navigation."
518538
(newline))
519539
;; Detail level 1: message + ex-data
520540
(cider-propertize-region '(detail 1)
521-
(cider-stacktrace-emit-indented
522-
(propertize (or message "(No message)") 'font-lock-face message-face) indent t)
541+
(let ((beg (point)))
542+
(cider-stacktrace-emit-indented
543+
(propertize (or message "(No message)") 'font-lock-face message-face) indent t)
544+
(cider-stacktrace--create-go-to-err-button beg message))
523545
(newline)
524546
(when data
525547
(cider-stacktrace-emit-indented

0 commit comments

Comments
 (0)