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

Files from outside "current project" adds to the problem count #1864

Closed jacobemcken closed 2 years ago

jacobemcken commented 2 years ago

I find the following behavior in Calva (lsp?) a bit annoying:

  1. Open your favorite project with fairly few "Problems"
  2. Open a file from outside your project to inspect some code
  3. See the "problem" count skyrocket :sweat_smile:
  4. Close the file outside your project again

Expected behavior: The "problem" count goes back down, when the file is closed.

Actual behavior: The problems from the "external" file lingers and now drown my "real" problems.

Workaround: Restart VS Code.

Also worth noting: Clear Document Diagnostics doesn't seem to work on "outside files". I reopen the problematic outside file in the hope that I can "clear diagnostics" and then quickly close it again before the problems are picked up.

PEZ commented 2 years ago

Thanks for reporting!

Pinging @ericdallo. It might be something we need to tell clojure-lsp when that file closes.

As for workarounds. A slightly less dramatic (depending on your usage of VS Code) way is to only reload the current window. One way to do so is to use the command Developer: Reload Window. You can even make the REPL survive this by starting it yourself and use Calva Connect instead of Jack-in. VS Code terminals survive window reloads. (Sadly this doesn't go for the Jack-in terminal yet.)

Clear Document Diagnostics doesn't seem to work on "outside files".

TIL. I didn't know about this command. Have been needing it! Anyway, this indicates that it might be a VS Code problem. We'll see.

ericdallo commented 2 years ago

I think it makes sense to count the errors while the file is opened but I agree that after receiving a didClose on server we should check if it's inside the project and update the diagnostics if not, please open a ticket on clojure-lsp

ericdallo commented 2 years ago

Fixed on clojure-lsp master, please test the nightly build

jacobemcken commented 2 years ago

I might not understand something, but using a "nightly" does not seem to have fixed the problem.

lsp nightly configuration
  1. I open my project from the folder ~/Private/Projects/my-project/ in VS Code/Calva with an initial "Problem count" of 2.
  2. I open a file outside my project folder ~/Private/Projects/mongo-driver-3/src/mongo_driver_3/operator.clj (cloned from Mongo Driver 3)
  3. "Problem count" rise to 363.
  4. Upon closing the file, the "Problem count" fall to 176
error count before error count after

Expectation: The "Problem count" would fall to 2 which it was initially.

ericdallo commented 2 years ago

@PEZ is that related to Calva not downloading nightly properly?

bpringe commented 2 years ago

@ericdallo It might be related. @jacobemcken A new version of Calva was released since your last comment that fixed an issue with the nightly build download. I would try it again and see if the problem persists.

jacobemcken commented 2 years ago

Tried again this morning using Calva version [2.0.304] - 2022-09-20.

Same problem (as in: the problem count goes somewhat down, but only around half... see screenshots about for example)

jacobemcken commented 2 years ago

@ericdallo do you want me to create an issue over at https://github.com/clojure-lsp/clojure-lsp ?

or is the bug somewhere else?... the nightly did reduce the number of warnings (see above screenshots).

ericdallo commented 2 years ago

@jacobemcken is there any repro I can try? The fix I made should fix cases like that

jacobemcken commented 2 years ago

Thanks for your patience @ericdallo The bug is fixed.

The reason why only some linting warnings would disappear once I closed the external file, was because I also had the clj-kondo VS Code extension installed. I don't know how many months I've been running double linting checks :scream:

Now that I've uninstalled that clj-kondo, I can verify that nightly fixes the issue for me. :pray:

ericdallo commented 2 years ago

Good, I think that 's more common that you think. Maybe we should present some warning when both are installed c/c @PEZ

bpringe commented 2 years ago

It appears I thought it was a good idea to remove that warning in the past 😅: https://github.com/BetterThanTomorrow/calva/issues/1091. Sorry @jacobemcken! I think we should add that back...