Skip to content

[stacktrace] Visual improvements, expand causes by 1 by default #3790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [#3782](https://github.com/clojure-emacs/cider/issues/3782): **(Breaking)** Drop official support for Emacs 26.
- [#3777](https://github.com/clojure-emacs/cider/issues/3777): Inspector no longer displays parsed Javadoc for Java classes and members.
- [#3784](https://github.com/clojure-emacs/cider/issues/3784): Inspector: make point less erratic when navigating between inspector screens.
- [#3790](https://github.com/clojure-emacs/cider/issues/3790): Stacktrace: show messages and data for all exception causes by default.

## 1.17.1 (2025-02-25)

Expand Down
22 changes: 10 additions & 12 deletions cider-stacktrace.el
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ The error types are represented as strings."
(setq-local electric-indent-chars nil)
(setq-local cider-stacktrace-hidden-frame-count 0)
(setq-local cider-stacktrace-filters cider-stacktrace-default-filters)
(setq-local cider-stacktrace-cause-visibility (make-vector 10 0))
;; Expand all exception causes to "detail level 1" by default, meaning they
;; will show the message and the data (but not the stacktrace).
(setq-local cider-stacktrace-cause-visibility (make-vector 10 1))
(buffer-disable-undo))


Expand Down Expand Up @@ -707,8 +709,7 @@ This associates text properties to enable filtering and source navigation."
(put-text-property p1 p4 'font-lock-face 'cider-stacktrace-ns-face)
(put-text-property p2 p3 'font-lock-face 'cider-stacktrace-fn-face)
(put-text-property (line-beginning-position) (line-end-position)
'cider-stacktrace-frame t)))
(insert "\n")))))))
'cider-stacktrace-frame t)))))))))

(defun cider-stacktrace-render-compile-error (buffer cause)
"Emit into BUFFER the compile error CAUSE, and enable jumping to it."
Expand Down Expand Up @@ -844,41 +845,38 @@ make INSPECT-INDEX actionable if present."
,cider-stacktrace-exception-map)
(insert (format "%d. " num)
(propertize note 'font-lock-face 'font-lock-comment-face) " "
(propertize class 'font-lock-face class-face 'mouse-face 'highlight)
"\n"))
(propertize class 'font-lock-face class-face 'mouse-face 'highlight)))
;; Detail level 1: message + ex-data
(cider-propertize-region '(detail 1)
(insert "\n")
(if (equal class "clojure.lang.Compiler$CompilerException")
(cider-stacktrace-render-compile-error buffer cause)
(cider-stacktrace-emit-indented
(propertize (or message "(No message)")
'font-lock-face message-face)
indent t))
(insert "\n")
(when spec
(insert "\n")
(cider-stacktrace--emit-spec-problems spec (concat indent " ")))
(when data
(insert "\n")
(cider-stacktrace-emit-indented data indent nil t)))
;; Detail level 2: stacktrace
(cider-propertize-region '(detail 2)
(insert "\n")
(let ((beg (point))
(bg `(:background ,cider-stacktrace-frames-background-color :extend t)))
(dolist (frame stacktrace)
(insert "\n")
(cider-stacktrace-render-frame buffer frame))
(overlay-put (make-overlay beg (point)) 'font-lock-face bg)))
;; Add line break between causes, even when collapsed.
(cider-propertize-region '(detail 0)
(insert "\n")))))))
(insert "\n\n")))))))

(defun cider-stacktrace-initialize (causes)
"Set and apply CAUSES initial visibility, filters, and cursor position."
(nrepl-dbind-response (car causes) (class)
(let ((compile-error-p (equal class "clojure.lang.Compiler$CompilerException")))
;; Partially display outermost cause if it's a compiler exception (the
;; description reports reader location of the error).
(when compile-error-p
(cider-stacktrace-cycle-cause (length causes) 1))
;; Fully display innermost cause. This also applies visibility/filters.
(cider-stacktrace-cycle-cause 1 cider-stacktrace-detail-max)
;; Move point (DWIM) to the compile error location if present, or to the
Expand Down