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

Some LSP requests should wait for debounced update #23

Open
bentsherman opened this issue Sep 2, 2024 · 0 comments · May be fixed by #24
Open

Some LSP requests should wait for debounced update #23

bentsherman opened this issue Sep 2, 2024 · 0 comments · May be fixed by #24

Comments

@bentsherman
Copy link
Member

I got nerd-sniped over the weekend while playing around with the language server. Saving my findings here for later.

Some LSP requests like document link, document symbol, and code lens are made automatically by the editor as a document is edited. They do appear to be debounced (at least in vscode), but the delay is shorter than ours, so these requests are often processed before the AST has been re-compiled. I have seen the document links fall out of sync for this reason.

I would like to make these LSP requests wait for the delayed update if it exists, since the change event always seems to arrive first. Something like this:

  1. on didChange, trigger a delayed update and set an "awaiting update" flag to true
  2. on document link/symbol request, if "awaiting update" is true, wait on an "updated" condition variable
  3. on update, signal the "updated" condition variable, unblocking all relevant LSP requests

The problem I'm seeing is the lock associated with the condition. If the requests need to acquire the lock in order to wait on the condition variable, then the update thread can't acquire that lock to signal the condition variable. Maybe I need to use a read-write lock to handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant