diff --git a/CHANGELOG.md b/CHANGELOG.md index d17f69c16..470e425d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### New features +- [#3366](https://github.com/clojure-emacs/cider/pull/3366): Support display of error overlays with #dbg! and #break! reader macros. - [#3622](https://github.com/clojure-emacs/cider/pull/3461): Basic support for using CIDER from [clojure-ts-mode](https://github.com/clojure-emacs/clojure-ts-mode). - The `clojure-mode` dependency is still required for CIDER to function. - Some features like `cider-dynamic-indentation` and `cider-font-lock-dynamically` do not work with `clojure-ts-mode` (yet). diff --git a/cider-debug.el b/cider-debug.el index f06a8c06b..5b9a69b38 100644 --- a/cider-debug.el +++ b/cider-debug.el @@ -125,14 +125,16 @@ configure `cider-debug-prompt' instead." (defun cider--debug-response-handler (response) "Handles RESPONSE from the cider.debug middleware." - (nrepl-dbind-response response (status id causes) + (nrepl-dbind-response response (status id causes caught-msg) (when (member "enlighten" status) (cider--handle-enlighten response)) (when (or (member "eval-error" status) (member "stack" status)) ;; TODO: Make the error buffer a bit friendlier when we're just printing ;; the stack. - (cider--render-stacktrace-causes causes)) + (if cider-show-error-buffer + (cider--render-stacktrace-causes causes) + (cider--debug-display-result-overlay nil caught-msg))) (when (member "need-debug-input" status) (cider--handle-debug response)) (when (member "done" status) @@ -154,15 +156,18 @@ configure `cider-debug-prompt' instead." #("." 0 1 (display (left-fringe right-triangle))) "Used as an overlay's before-string prop to place a fringe arrow.") -(defun cider--debug-display-result-overlay (value) - "Place an overlay at point displaying VALUE." +(defun cider--debug-display-result-overlay (value caught) + "Place an overlay at point displaying VALUE. +When CAUGHT is non-nil, display it as an error message overlay." (when cider-debug-use-overlays ;; This is cosmetic, let's ensure it doesn't break the session no matter what. (ignore-errors ;; Result - (cider--make-result-overlay (cider-font-lock-as-clojure value) + (cider--make-result-overlay (or caught (cider-font-lock-as-clojure value)) :where (point-marker) :type 'debug-result + :prepend-face (if caught 'cider-error-overlay-face + 'cider-result-overlay-face) 'before-string cider--fringe-arrow-string) ;; Code (cider--make-overlay (save-excursion (clojure-backward-logical-sexp 1) (point)) @@ -652,7 +657,7 @@ is a coordinate measure in sexps." RESPONSE is a message received from the nrepl describing the input needed. It is expected to contain at least \"key\", \"input-type\", and \"prompt\", and possibly other entries depending on the input-type." - (nrepl-dbind-response response (debug-value key input-type prompt inspect) + (nrepl-dbind-response response (debug-value key input-type prompt inspect caught-msg) (condition-case-unless-debug e (progn (pcase input-type @@ -674,7 +679,7 @@ needed. It is expected to contain at least \"key\", \"input-type\", and ;; flicker even if we immediately recreate the overlays. (cider--debug-remove-overlays) (when cider-debug-use-overlays - (cider--debug-display-result-overlay debug-value)) + (cider--debug-display-result-overlay debug-value caught-msg)) (setq cider--debug-mode-response response) (cider--debug-mode 1))) (when inspect @@ -766,7 +771,7 @@ The boolean value of FORCE will be sent in the reply." ;; Is HERE inside the sexp being debugged? (when (or (< here (point)) (save-excursion - (forward-sexp 1) + (clojure-forward-logical-sexp 1) (> here (point)))) (user-error "Point is outside the sexp being debugged")) ;; Move forward until start of sexp.