BetterThanTomorrow / calva

Clojure & ClojureScript Interactive Programming for VS Code
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
Other
1.67k stars 217 forks source link

Navigating to a symbol sometimes starts using incorrect location after refactoring #1260

Open p-himik opened 3 years ago

p-himik commented 3 years ago

I have a file that I just refactored into two smaller files. After that, jumping to a symbol sends me to a wrong location. E.g. I have a function get-random-angles that's defined on line 187 after the refactoring. When I click on it, the "Clojure Language Client" has this section in its output, among other things:

            {
                "name": "get-random-angles",
                "kind": 12,
                "range": {
                    "start": {
                        "line": 186,
                        "character": 0
                    },
                    "end": {
                        "line": 192,
                        "character": 13
                    }
                },
                "selectionRange": {
                    "start": {
                        "line": 186,
                        "character": 6
                    },
                    "end": {
                        "line": 186,
                        "character": 23
                    }
                }
            },

So seems like Clojure-lsp is correct. But Calva sends me to line 230 instead. I suspect that's the location of the function before the refactoring. Similar thing happens with other symbols. Navigating to symbols that are defined in unchanged files works just fine.

Restarting VSCode fixed the issue and I couldn't reproduce it anymore - neither in the same project nor in a new one. Perhaps there's some cache in Calva that sometimes isn't getting cleared.

PEZ commented 3 years ago

This could be that it is nREPL that is providing the location. So if you haven't reloaded the files, I guess it could be using outdated knowledge about them.

Leaving this open, because I want to understand what is happening and figure if we can make it better somehow. If my guess about nREPL is right there, maybe we can prioritize clojure-lsp's answer (we ask both today, and maybe we are picking nREPL first, I need to check).

p-himik commented 3 years ago

Oh, interesting! At the moment, is there a way to select just clojure-lsp at the user level, without changing Calva code?

PEZ commented 3 years ago

There isn't. Likely won't be, either. 😄 If yo encounter this again, see if reloading the file helps, please. I will too. Think I've seen this a few times, but didn't bother to investigate then.