Skip to content

Commit 6d3247d

Browse files
committed
Tidy up friendly-session matcher after review
* Use `string-suffix-p` instead of an anchored regex for JAR detection. * Use `delq nil` instead of `seq-remove #'null', matching codebase style. * Tighten the connect-handler comment to one sentence. * Soften the matcher's "never blocks" docstring claim (the ns/buffer fallbacks can still hit the REPL). * Explain why classpath uses `string-prefix-p` while classpath-roots uses `file-in-directory-p` -- the two are intentionally asymmetric.
1 parent b96e5d9 commit 6d3247d

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

lisp/cider-connection.el

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,8 @@ buffer."
302302
(when cider-repl-init-function
303303
(funcall cider-repl-init-function))
304304

305-
;; Populate the friendly-session matcher cache before enabling
306-
;; `cider-mode' on existing Clojure buffers -- that mode-enable can
307-
;; trigger sesman queries (mode-line refresh, etc.) which would
308-
;; otherwise hit an empty cache.
305+
;; Populate caches before `cider-enable-on-existing-clojure-buffers',
306+
;; whose mode-line refresh path calls the friendly-session matcher.
309307
(cider--precompute-friendly-session-cache)
310308

311309
(when cider-auto-mode

lisp/cider-repl.el

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,9 +1787,9 @@ to the project-dir / ns-form fallbacks in the matcher."
17871787
(process-put proc :cached-classpath classpath)
17881788
(process-put proc :cached-classpath-roots
17891789
(thread-last classpath
1790-
(seq-filter (lambda (path) (not (string-match-p "\\.jar$" path))))
1790+
(seq-remove (lambda (path) (string-suffix-p ".jar" path)))
17911791
(mapcar #'file-name-directory)
1792-
(seq-remove #'null)
1792+
(delq nil)
17931793
(seq-uniq))))
17941794
(when (cider-nrepl-op-supported-p "cider/ns-list")
17951795
(process-put proc :all-namespaces
@@ -1815,8 +1815,8 @@ The checking is done as follows:
18151815
matches any of the loaded namespaces.
18161816
18171817
Classpath/namespace caches are populated eagerly at connection time
1818-
by `cider--precompute-friendly-session-cache', so this function is a
1819-
pure path comparison and never blocks on the REPL."
1818+
by `cider--precompute-friendly-session-cache', so this function
1819+
avoids blocking on classpath/ns-list fetches."
18201820
(setcdr session (seq-filter #'buffer-live-p (cdr session)))
18211821
(when-let ((repl (cadr session)))
18221822
(cond
@@ -1851,6 +1851,9 @@ pure path comparison and never blocks on the REPL."
18511851
(classpath-roots (process-get proc :cached-classpath-roots))
18521852
(ns-list (process-get proc :all-namespaces))
18531853
(proj-dir (buffer-local-value 'nrepl-project-dir repl)))
1854+
;; Classpath entries can be JAR files (matched as path prefixes of
1855+
;; archive-internal paths); roots are real directories and need a
1856+
;; proper directory-boundary check.
18541857
(or (seq-find (lambda (path) (string-prefix-p path file))
18551858
classpath)
18561859
(seq-find (lambda (path) (file-in-directory-p file path))

0 commit comments

Comments
 (0)