clojure-lsp / clojure-lsp

Clojure & ClojureScript Language Server (LSP) implementation

Home Page:https://clojure-lsp.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rename ns picks wrong source-path

opqdonut opened this issue · comments

Describe the bug

Performing a rename of namespace foo.bar (living in src/cljs/foo/bar.clj) to foo.quux results in file src/clj/foo/quux.clj. The source-path changes from src/cljs to src/clj.

To Reproduce

  • M-x lsp-rename
  • foo.bar to foo.quux

Expected behavior

I expect the renamed ns to stay within the same source-path.

User details (please complete the following information):

  • OS: MacOs
  • Editor: Emacs
  • Version: 2024.03.31-19.15.11-nightly

Additional context

We think the bug is in filename->source-paths. It uses string/starts-with? which gives a false positive on src/clj because src/cljs/... indeed starts with src/clj!

(filter #(string/starts-with? filename %) source-paths))

To test this theory we changed the project config to have src/aljs and src/clj. After that the rename uses the right source-path.

We're willing to make a PR.