Skip to content

Commit

Permalink
[Fix clojure-emacs#2628] Don't try to font-lock multi-chunk results i…
Browse files Browse the repository at this point in the history
…n the REPL

Also fixes clojure-emacs#1971.
  • Loading branch information
bbatsov committed May 18, 2020
1 parent 8c5fb8f commit e0c2a2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

* [#2839](https://github.com/clojure-emacs/cider/pull/2839): Fix symbol-at-point on var-quoted symbols.
* [#2807](https://github.com/clojure-emacs/cider/pull/2807): Fix require-repl-utils for shadow-cljs repls.
* [#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.

## 0.24.0 (2020-02-15)

Expand Down
9 changes: 8 additions & 1 deletion cider-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ This buffer is not designed to display anything to the user. For that, use
(with-current-buffer (cider--make-buffer-for-mode mode)
(erase-buffer)
(insert string)
;; don't try to font-lock unbalanced Clojure code
(when (eq mode 'clojure-mode)
(check-parens))
(font-lock-fontify-region (point-min) (point-max))
(buffer-string))
string)))
Expand All @@ -329,7 +332,11 @@ Unless you specify a BUFFER it will default to the current one."

(defun cider-font-lock-as-clojure (string)
"Font-lock STRING as Clojure code."
(cider-font-lock-as 'clojure-mode string))
;; If something goes wrong (e.g. the code is not balanced)
;; we simply return the string.
(condition-case nil
(cider-font-lock-as 'clojure-mode string)
(error string)))

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

0 comments on commit e0c2a2e

Please sign in to comment.