Skip to content

Commit 612e374

Browse files
authored
Don't apply dynamic syntax highlighting over buffers belonging to unrelated Sesman sessions (#3560)
Fixes #3559
1 parent 86b3f95 commit 612e374

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Bugs fixed
6+
7+
- [#3559](https://github.com/clojure-emacs/cider/issues/3559): don't apply [dynamic syntax highlighting](https://docs.cider.mx/cider/config/syntax_highlighting.html) over buffers belonging to unrelated Sesman sessions.
8+
59
## 1.9.0 (2023-10-24)
610

711
### New features

cider-repl.el

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,26 @@ This cache is stored in the connection buffer.")
246246
(setq cider-repl-cljs-upgrade-pending nil))
247247
(unless (nrepl-dict-empty-p changed-namespaces)
248248
(setq cider-repl-ns-cache (nrepl-dict-merge cider-repl-ns-cache changed-namespaces))
249-
(dolist (b (buffer-list))
250-
(with-current-buffer b
251-
;; Metadata changed, so signatures may have changed too.
252-
(setq cider-eldoc-last-symbol nil)
253-
(when (or cider-mode (derived-mode-p 'cider-repl-mode))
254-
(when-let* ((ns-dict (or (nrepl-dict-get changed-namespaces (cider-current-ns))
255-
(let ((ns-dict (cider-resolve--get-in (cider-current-ns))))
256-
(when (seq-find (lambda (ns) (nrepl-dict-get changed-namespaces ns))
257-
(nrepl-dict-get ns-dict "aliases"))
258-
ns-dict)))))
259-
(cider-refresh-dynamic-font-lock ns-dict))))))))))
249+
(let ((this-repl (current-buffer)))
250+
(dolist (b (buffer-list))
251+
(with-current-buffer b
252+
(when (or cider-mode (derived-mode-p 'cider-repl-mode))
253+
;; We only cider-refresh-dynamic-font-lock (and set `cider-eldoc-last-symbol')
254+
;; for Clojure buffers directly related to this repl
255+
;; (specifically, we omit 'friendly' sessions because a given buffer may be friendly to multiple repls,
256+
;; so we don't want a buffer to mix up font locking rules from different repls).
257+
;; Note that `sesman--linked-sessions' only queries for the directly linked sessions.
258+
;; That has the additional advantage of running very/predictably fast, since it won't run our
259+
;; `cider--sesman-friendly-session-p' logic, which can be slow for its non-cached path.
260+
(when (member this-repl (car (sesman--linked-sessions 'CIDER)))
261+
;; Metadata changed, so signatures may have changed too.
262+
(setq cider-eldoc-last-symbol nil)
263+
(when-let* ((ns-dict (or (nrepl-dict-get changed-namespaces (cider-current-ns))
264+
(let ((ns-dict (cider-resolve--get-in (cider-current-ns))))
265+
(when (seq-find (lambda (ns) (nrepl-dict-get changed-namespaces ns))
266+
(nrepl-dict-get ns-dict "aliases"))
267+
ns-dict)))))
268+
(cider-refresh-dynamic-font-lock ns-dict))))))))))))
260269

261270
(defun cider-repl-require-repl-utils ()
262271
"Require standard REPL util functions into the current REPL."

0 commit comments

Comments
 (0)