Skip to content

Commit 8b2ef5f

Browse files
Limit the maximum string size to be displayed in echo area
1 parent b421bbb commit 8b2ef5f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- [#3626](https://github.com/clojure-emacs/cider/issues/3626): `cider-ns-refresh`: jump to the relevant file/line on errors.
1919
- [#3628](https://github.com/clojure-emacs/cider/issues/3628): `cider-ns-refresh`: summarize errors as an overlay.
2020
- [#3660](https://github.com/clojure-emacs/cider/issues/3660): Fix `cider-inspector-def-current-val` always defining in `user` namespace.
21+
- [#3661](https://github.com/clojure-emacs/cider/issues/3661): Truncate echo area output ahead of time.
2122
- Bump the injected `enrich-classpath` to [1.19.3](https://github.com/clojure-emacs/enrich-classpath/compare/v1.19.0...v1.19.3).
2223
- Bump the injected nREPL to [1.1.1](https://github.com/nrepl/nrepl/blob/v1.1.1/CHANGELOG.md#111-2024-02-20).
2324
- 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).

cider-overlays.el

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ Note that, while POINT can be a number, it's preferable to be a marker, as
304304
that will better handle some corner cases where the original buffer is not
305305
focused."
306306
(cl-assert (symbolp value-type)) ;; We assert because for avoiding confusion with the optional args.
307-
(let* ((font-value (if cider-result-use-clojure-font-lock
307+
(let* ((value (string-trim-right value))
308+
(font-value (if cider-result-use-clojure-font-lock
308309
(cider-font-lock-as-clojure value)
309310
value))
310-
(font-value (string-trim-right font-value))
311311
(used-overlay (when (and point
312312
cider-use-overlays
313313
(if (equal 'error value-type)
@@ -316,10 +316,15 @@ focused."
316316
(cider--make-result-overlay font-value
317317
:where point
318318
:duration cider-eval-result-duration
319-
:prepend-face (or overlay-face 'cider-result-overlay-face)))))
319+
:prepend-face (or overlay-face 'cider-result-overlay-face))))
320+
(msg (format "%s%s" cider-eval-result-prefix value))
321+
(max-msg-length (* (floor (max-mini-window-lines)) (frame-width)))
322+
(msg (if (> (string-width msg) max-msg-length)
323+
(format "%s..." (substring msg 0 (- max-msg-length 3)))
324+
msg)))
320325
(message
321326
"%s"
322-
(propertize (format "%s%s" cider-eval-result-prefix font-value)
327+
(propertize msg
323328
;; The following hides the message from the echo-area, but
324329
;; displays it in the Messages buffer. We only hide the message
325330
;; if the user wants to AND if the overlay succeeded.

0 commit comments

Comments
 (0)