While running the regressions, I came across this test in code_actions_test.clj:
(deftest sort-clauses-actions
(swap! (h/db*) shared/deep-merge {:client-capabilities {:workspace {:workspace-edit {:document-changes true}}}})
(h/load-code-and-locs (h/code "(ns some-ns)"
""
"(defn foo []"
" {:g 2 :s 3 :kj 3 :a 5})"))
(testing "on map bracket"
(h/assert-contains-submaps
[{:title "Sort map"
:command {:command "sort-clauses"}}]
(f.code-actions/all (zloc-of (h/file-uri "file:///a.clj"))
(h/file-uri "file:///project/src/some_ns.clj")
4
3
[]
{:workspace {:workspace-edit true}}
(h/db))))
It seems like h/db has all the references loaded into the "file:///a.clj" URI, not "file:///project/src/some_ns.clj". Queries against the uri passed to code-actions/all then fail.
I did try changing the test's URI, and that works.
1. Is the test currently incorrect?
2. Is this something that could reasonably happen at runtime (and should be checked in the clojure-lsp code)?yeah looks like a wrong test, we should have used the same URI, preferable with the project to simulate a real project with source-paths
your change looks good
Just for reference: here are the changes I made:
(h/load-code-and-locs (h/code "(ns some-ns)"
""
"(defn foo []"
" {:g 2 :s 3 :kj 3 :a 5})")
"file:///project/src/some_ns.clj")
(testing "on map bracket"
(h/assert-contains-submaps
[{:title "Sort map"
:command {:command "sort-clauses"}}]
(f.code-actions/all (zloc-of (h/file-uri "file:///project/src/some_ns.clj"))
(h/file-uri "file:///project/src/some_ns.clj")
4
3
[]
{:workspace {:workspace-edit true}}
(h/db))))@ericdallo I submitted PR, but my fix breaks on windows. 😞 https://github.com/clojure-lsp/clojure-lsp/actions/runs/22876605611/job/66369661491?pr=2240 I don't have a windows box to test on, but I suspect it's the path. I'll experiment with it some
Usually it's easy as wrap uris with h/file-uri or h/file-path
Ah! Thanks. I'll check it out
I'd say you missed a h/file uri https://github.com/clojure-lsp/clojure-lsp/pull/2240/changes#diff-c04a22f0e11a6610a947461d4e09723ba90d096d90f2ac3f97cf800ba2f8dc2aR853
Doh! Thanks!