Skip to content

Commit bd55ba2

Browse files
dpsuttonbbatsov
authored andcommitted
[Fix #2787] Generate correct special buffer names for sibling buffers (#2788)
nrepl-hide-special-buffers would prepend a leading space to the nrepl process buffer to hide it from the buffer list. If you created a new sibling process there was a bug however. In order to uniquely name buffers, CIDER uses `generate-new-buffer-name` to ensure a buffer is uniquely named. However, the space was put on _after_ this call. The sequence is as follows: - jack in - use template "*cider-nrepl blah" to see if existing process buffer is around. Its not. Since we want these hidden, add a leading space so now " *cider-nrepl blah*" process buffer exists - watch for "nREPL server started on port \\([0-9]+\\)" and not already a port saved - start repl - jack in again creating sibling process - check if buffer "*cider-nrepl blah" exists. It doesn't since the first one has a leading space - add a leading space to the buffer name to get " *cider-nrepl blah" which actually now is a collision - lein/deps/shadow startup output goes in the same buffer as the other process and therefore no new repl is started up when watching the the process output since the following code is waiting: ```lisp (when (and (null nrepl-endpoint) (string-match "nREPL server started on port \\([0-9]+\\)" output)) ```
1 parent d4c7e6c commit bd55ba2

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGELOG.md

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

55
### New features
66

7+
* [#2787](https://github.com/clojure-emacs/cider/issues/2787): Fix nrepl process naming collision when using `nrepl-hide-special-buffers`
78
* [#2744](https://github.com/clojure-emacs/cider/pull/2744): Add startup commands to repl banner.
89
* [#2499](https://github.com/clojure-emacs/cider/issues/2499): Add `cider-jump-to-pop-to-buffer-actions`.
910
* [#2738](https://github.com/clojure-emacs/cider/pull/2738): Add ability to lookup a function symbol when cursor is at the opening paren.

nrepl-client.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ PARAMS and DUP-OK are as in `nrepl-make-buffer-name'."
203203
(defun nrepl-server-buffer-name (params)
204204
"Return the name of the server buffer.
205205
PARAMS is as in `nrepl-make-buffer-name'."
206-
(nrepl--make-hidden-name
207-
(nrepl-make-buffer-name nrepl-server-buffer-name-template params)))
206+
(nrepl-make-buffer-name (nrepl--make-hidden-name nrepl-server-buffer-name-template)
207+
params))
208208

209209
(defun nrepl-tunnel-buffer-name (params)
210210
"Return the name of the tunnel buffer.
211211
PARAMS is as in `nrepl-make-buffer-name'."
212-
(nrepl--make-hidden-name
213-
(nrepl-make-buffer-name nrepl-tunnel-buffer-name-template params)))
212+
(nrepl-make-buffer-name (nrepl--make-hidden-name nrepl-tunnel-buffer-name-template)
213+
params))
214214

215215
(defun nrepl-messages-buffer-name (params)
216216
"Return the name for the message buffer given connection PARAMS."

test/nrepl-client-tests.el

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@
4343
(setq nrepl-hide-special-buffers t
4444
nrepl-server-buffer-name-template "*nrepl-server %h:%p*")
4545
(expect (nrepl-server-buffer-name params)
46-
:to-equal " *nrepl-server localhost:1*"))))
46+
:to-equal " *nrepl-server localhost:1*"))
47+
(it "creates two separate server processes if needed"
48+
(setq nrepl-hide-special-buffers t
49+
nrepl-server-buffer-name-template "*cider-test-buffer-names*")
50+
(let ((first-buffer (nrepl-server-buffer-name params)))
51+
(expect first-buffer :to-equal " *cider-test-buffer-names*")
52+
(get-buffer-create first-buffer)
53+
(expect (nrepl-server-buffer-name params)
54+
:not :to-equal first-buffer)))))
4755

4856

4957
(describe "nrepl-dbind-response"

0 commit comments

Comments
 (0)