diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dec7138b..caa324514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - [#3626](https://github.com/clojure-emacs/cider/issues/3626): `cider-ns-refresh`: jump to the relevant file/line on errors. - [#3628](https://github.com/clojure-emacs/cider/issues/3628): `cider-ns-refresh`: summarize errors as an overlay. - [#3660](https://github.com/clojure-emacs/cider/issues/3660): Fix `cider-inspector-def-current-val` always defining in `user` namespace. +- [#3661](https://github.com/clojure-emacs/cider/issues/3661): Truncate echo area output ahead of time. - Bump the injected `enrich-classpath` to [1.19.3](https://github.com/clojure-emacs/enrich-classpath/compare/v1.19.0...v1.19.3). - Bump the injected nREPL to [1.1.1](https://github.com/nrepl/nrepl/blob/v1.1.1/CHANGELOG.md#111-2024-02-20). - Bump the injected `cider-nrepl` to [0.47.0](https://github.com/clojure-emacs/cider-nrepl/blob/v0.47.0/CHANGELOG.md#0470-2024-03-10). diff --git a/cider-overlays.el b/cider-overlays.el index 6310bb0d3..733258166 100644 --- a/cider-overlays.el +++ b/cider-overlays.el @@ -304,10 +304,10 @@ Note that, while POINT can be a number, it's preferable to be a marker, as that will better handle some corner cases where the original buffer is not focused." (cl-assert (symbolp value-type)) ;; We assert because for avoiding confusion with the optional args. - (let* ((font-value (if cider-result-use-clojure-font-lock + (let* ((value (string-trim-right value)) + (font-value (if cider-result-use-clojure-font-lock (cider-font-lock-as-clojure value) value)) - (font-value (string-trim-right font-value)) (used-overlay (when (and point cider-use-overlays (if (equal 'error value-type) @@ -316,10 +316,15 @@ focused." (cider--make-result-overlay font-value :where point :duration cider-eval-result-duration - :prepend-face (or overlay-face 'cider-result-overlay-face))))) + :prepend-face (or overlay-face 'cider-result-overlay-face)))) + (msg (format "%s%s" cider-eval-result-prefix value)) + (max-msg-length (* (floor (max-mini-window-lines)) (frame-width))) + (msg (if (> (string-width msg) max-msg-length) + (format "%s..." (substring msg 0 (- max-msg-length 3))) + msg))) (message "%s" - (propertize (format "%s%s" cider-eval-result-prefix font-value) + (propertize msg ;; The following hides the message from the echo-area, but ;; displays it in the Messages buffer. We only hide the message ;; if the user wants to AND if the overlay succeeded.