lsp

JR 2026-02-28T02:24:56.371589Z

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)?

ericdallo 2026-02-28T15:48:41.330479Z

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

👍 1
ericdallo 2026-02-28T15:48:52.419429Z

your change looks good

JR 2026-02-28T02:25:37.878209Z

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))))

JR 2026-03-09T22:07:45.192189Z

@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

ericdallo 2026-03-09T22:08:22.583049Z

Usually it's easy as wrap uris with h/file-uri or h/file-path

JR 2026-03-09T22:08:43.095469Z

Ah! Thanks. I'll check it out

JR 2026-03-09T22:11:25.592809Z

Doh! Thanks!

😅 1