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

LSP call stream emptiness check is incorrect (?) #5413

Closed
jakubDoka opened this issue Jan 5, 2023 · 4 comments
Closed

LSP call stream emptiness check is incorrect (?) #5413

jakubDoka opened this issue Jan 5, 2023 · 4 comments
Labels
A-language-server Area: Language server client C-bug Category: This is a bug

Comments

@jakubDoka
Copy link

jakubDoka commented Jan 5, 2023

Summary

When testing lsp for my language, is noticed that spinner stays frozen and no diagnostics show up on screen until I move cursor which is different from what rust extension does. I thought I am missing something, so i looked into source code.

I found this:

                self.handle_language_server_message(call, id).await;
                // limit render calls for fast language server messages
                let last = self.editor.language_servers.incoming.is_empty();

                if last || self.last_render.elapsed() > LSP_DEADLINE {
                    self.render().await;
                    self.last_render = Instant::now();
                }

is_empty will return true if there are no streams present.
Since lsp_servers holds the stream until client with UnboundedSender is dropped, last will only be true when there is no server active.

LSP_DEADLINE is 16ms but My language server can update reliably faster. By adding thread::sleep to server code i managed to fix it, though It was not very easy to figure out.

My expectations were that upon progress end notification, editor would clear the spinners but it, only stops them (possible fix).

Reproduction Steps

No response

Helix log

No response

Platform

Linux

Terminal Emulator

Ubuntu 20.04.5 LTS

Helix Version

helix 22.12 (6c95411)

@jakubDoka jakubDoka added the C-bug Category: This is a bug label Jan 5, 2023
@kirawi kirawi added the A-language-server Area: Language server client label Jan 9, 2023
@the-mikedavis
Copy link
Member

I also see this frequently with erlang_ls, I think because it sends many progress update messages and then the progress-done or publishDiagnostics messages. The important events don't trigger the rendering since they arrive within the 16ms window after a progress message. I can't seem to figure out the proper incantation to check if there are any events pending in any streams without consuming the events though 🤔. I've added this hack to my fork in the meantime: the-mikedavis@d2034ac

@jakubDoka
Copy link
Author

Maybe good solution would be listing on which LSP events should helix rerender, inside the config.

@the-mikedavis
Copy link
Member

I think it would be best to keep this automatic if possible. Debouncing the rendering should be an implementation detail IMO

Another approach we could take to this would be setting a timer to go off after the LSP deadline. Roughly:

if last || self.last_render.elapsed() > LSP_DEADLINE {
    self.render().await;
    self.last_render = Instant::now();
} else {
    self.render_timer.reset(Instant::now() + LSP_DEADLINE)
}

And then rendering at the end of that timer. But I'm not sure how cheap it is to reset timers really often.

@pascalkuthe
Copy link
Member

Fixed by #7538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

4 participants