Skip to content

Commit e0c2a2e

Browse files
committed
[Fix #2628] Don't try to font-lock multi-chunk results in the REPL
Also fixes #1971.
1 parent 8c5fb8f commit e0c2a2e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
* [#2839](https://github.com/clojure-emacs/cider/pull/2839): Fix symbol-at-point on var-quoted symbols.
2424
* [#2807](https://github.com/clojure-emacs/cider/pull/2807): Fix require-repl-utils for shadow-cljs repls.
25+
* [#1971](https://github.com/clojure-emacs/cider/issues/1971), [#2628](https://github.com/clojure-emacs/cider/issues/2628): Don't try to font-lock multi-chunk results in the REPL.
2526

2627
## 0.24.0 (2020-02-15)
2728

cider-util.el

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ This buffer is not designed to display anything to the user. For that, use
313313
(with-current-buffer (cider--make-buffer-for-mode mode)
314314
(erase-buffer)
315315
(insert string)
316+
;; don't try to font-lock unbalanced Clojure code
317+
(when (eq mode 'clojure-mode)
318+
(check-parens))
316319
(font-lock-fontify-region (point-min) (point-max))
317320
(buffer-string))
318321
string)))
@@ -329,7 +332,11 @@ Unless you specify a BUFFER it will default to the current one."
329332

330333
(defun cider-font-lock-as-clojure (string)
331334
"Font-lock STRING as Clojure code."
332-
(cider-font-lock-as 'clojure-mode string))
335+
;; If something goes wrong (e.g. the code is not balanced)
336+
;; we simply return the string.
337+
(condition-case nil
338+
(cider-font-lock-as 'clojure-mode string)
339+
(error string)))
333340

334341
;; Button allowing use of `font-lock-face', ignoring any inherited `face'
335342
(define-button-type 'cider-plain-button

0 commit comments

Comments
 (0)