Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The SymbolProvider line info gets out of whack when editing the file in Calva #1178

Closed
PEZ opened this issue Aug 10, 2022 · 5 comments · Fixed by #1180
Closed

The SymbolProvider line info gets out of whack when editing the file in Calva #1178

PEZ opened this issue Aug 10, 2022 · 5 comments · Fixed by #1180
Assignees
Labels
bug Something isn't working editor Related to clojure-lsp on a text editor

Comments

@PEZ
Copy link
Contributor

PEZ commented Aug 10, 2022

If I edit the file, adding/removing lines, then the Outline links to the wrong locations of the file.

This gets extra problematic with the new Sticky Scroll feature of VS Code, where the symbol provider is used to inform what should stick while scrolling. Here's an issue where this is clarified by the VS Code team:

To Reproduce

  1. Open a Clojure file in Calva
  2. Confirm that the Outline navigation works
  3. Add a line
  4. The Outline now navigates to lines offset by -1 for symbols after where you added the line.

What's a bit extra strange here is that if I undo the change of adding a line, the Outline now links to incorrect line offset by +1.

Expected behavior

The outline should navigate to the new line locations of the symbols is lists as the file is edited.

Log - client <-> server
Sure, I can add this, but in a bit of a hurry here. Please let me know if it would help with a log.
Log - clojure-lsp
Same.

User details (please complete the following information):

  • OS: [e.g. ArchLinux, MacOS, Windows 10]
  • Editor [e.g. emacs, nvim, VSCode (Calva)]
  • Version: (post the result of clojure-lsp --version)

Additional context
Add any other context about the problem here.

@PEZ PEZ added bug Something isn't working editor Related to clojure-lsp on a text editor labels Aug 10, 2022
@PEZ
Copy link
Contributor Author

PEZ commented Aug 10, 2022

Related to this is that sticky scrolling in VS Code would get much better if the Outline would have some more depth. Currently it seems to only include top level symbols?

@mainej mainej self-assigned this Aug 10, 2022
@mainej
Copy link
Collaborator

mainej commented Aug 10, 2022

clojure-lsp bases its documentSymbol data on the file's analysis. But, at the moment it doesn't wait for any currently running analysis to finish before replying to a documentSymbol request. My guess is that Calva sends didChange, which starts an (asynchronous) analysis, and then immediately documentSymbol. The second request uses the analysis that already exists, which, assuming the analysis hasn't finished, is for the prior version of the file. That's why the first edit is off by -1 and undoing is off by +1. In each case, clojure-lsp is providing documentSymbol data for how the file was a moment ago.

If I'm right, that's a really quick fix. I'll see if I can reproduce the problem and whether I can fix it.

mainej added a commit that referenced this issue Aug 10, 2022
Wait for analysis of file before responding to document-symbol.

Fixes #1178
mainej added a commit that referenced this issue Aug 10, 2022
Wait for analysis of file before responding to document-symbol.

Fixes #1178
@mainej
Copy link
Collaborator

mainej commented Aug 10, 2022

@PEZ I believe #1180 will fix this.

@ericdallo
Copy link
Member

Looks good and makes sense @mainej, @PEZ would you mind test with that PR's clojure-lsp?

mainej added a commit that referenced this issue Aug 10, 2022
Wait for analysis of file before responding to document-symbol.

Fixes #1178
mainej added a commit that referenced this issue Aug 11, 2022
Wait for analysis of file before responding to document-symbol.

Fixes #1178
mainej added a commit that referenced this issue Aug 11, 2022
Wait for analysis of file before responding to document-symbol.

Fixes #1178
@aiday-mar
Copy link

Hi I link hereby the relevant sticky scroll issue : microsoft/vscode#157630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editor Related to clojure-lsp on a text editor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants