diff --git a/CHANGELOG.md b/CHANGELOG.md index bbca18a84..8b48820ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - [#3331](https://github.com/clojure-emacs/cider/issues/3331): `cider-eval`: never jump to spurious locations, as sometimes conveyed by nREPL. - [#3112](https://github.com/clojure-emacs/cider/issues/3112): Fix the CIDER `xref-find-references` backend to return correct filenames. - [#3393](https://github.com/clojure-emacs/cider/issues/3393): recompute namespace info on each shadow-cljs recompilation or evaluation. +- [#3250](https://github.com/clojure-emacs/cider/issues/3250): don't lose the CIDER session over TRAMP files. - Fix the `xref-find-definitions` CIDER backend to return correct filenames. - Fix the `cider-xref-fn-deps` buttons to direct to the right file. - Make TRAMP functionality work when using non-standard ports. diff --git a/cider-connection.el b/cider-connection.el index 9ada65229..b498f2609 100644 --- a/cider-connection.el +++ b/cider-connection.el @@ -613,6 +613,14 @@ REPL defaults to the current REPL." "Figure out if SESSION1 or SESSION2 is more relevant." (sesman-more-recent-p (cdr session1) (cdr session2))) +(defun remove-string-prefix (prefix str) + "Remove PREFIX from the beginning of STR, if it is present. +Otherwise, return the original string." + (if (and (string-prefix-p prefix str) + (>= (length str) (length prefix))) + (substring str (length prefix)) + str)) + (declare-function cider-classpath-entries "cider-client") (cl-defmethod sesman-friendly-session-p ((_system (eql CIDER)) session) "Check if SESSION is a friendly session." @@ -624,6 +632,8 @@ REPL defaults to the current REPL." (when (string-match-p "#uzip" file) (let ((avfs-path (directory-file-name (expand-file-name (or (getenv "AVFSBASE") "~/.avfs/"))))) (setq file (replace-regexp-in-string avfs-path "" file t t)))) + (when-let ((tp (cider-tramp-prefix (current-buffer)))) + (setq file (remove-string-prefix tp file))) (when (process-live-p proc) (let* ((classpath (or (process-get proc :cached-classpath) (let ((cp (with-current-buffer repl