Skip to content

Commit 0ca359f

Browse files
committed
[#912] Improve a bit the robustness of the cider-restart command
1 parent f889460 commit 0ca359f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cider-interaction.el

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,12 +1783,16 @@ Quitting closes all active nREPL connections and kills all CIDER buffers."
17831783
If PROMPT-PROJECT is t, then prompt for the project in which to
17841784
restart the server."
17851785
(interactive "P")
1786-
(cider-quit)
1787-
;; Workaround for a nasty race condition https://github.com/clojure-emacs/cider/issues/439
1788-
;; TODO: Find a better way to ensure `cider-quit' has finished
1789-
(message "Waiting for CIDER to quit...")
1790-
(sleep-for 2)
1791-
(cider-jack-in prompt-project))
1786+
(let ((project-dir (with-current-buffer (nrepl-current-connection-buffer) nrepl-project-dir)))
1787+
(cider-quit)
1788+
;; Workaround for a nasty race condition https://github.com/clojure-emacs/cider/issues/439
1789+
;; TODO: Find a better way to ensure `cider-quit' has finished
1790+
(message "Waiting for CIDER to quit...")
1791+
(sleep-for 2)
1792+
(if project-dir
1793+
(let ((default-directory project-dir))
1794+
(cider-jack-in prompt-project))
1795+
(error "Can't restart CIDER for unknown project"))))
17921796

17931797
(add-hook 'nrepl-connected-hook 'cider-enable-on-existing-clojure-buffers)
17941798
(add-hook 'nrepl-disconnected-hook

0 commit comments

Comments
 (0)