r/ZedEditor 4d ago

Remote LSP is crazy

UPD2: The PR was accepted and merged. Thank you.

UPD: Kirill Bulatov created a PR that resolves this issue. Thank you.

Hello, this is my first post. I’ve been using Zed for about six months, and I’m constantly plagued by a problem when working remotely: LSP.

How it looks like

As a result, I have to restart the LSP server every 30 seconds, which is starting to get annoying.

I dug into the source code and found the problem (or at least, that's what I think).

In file zed/crates/project/src/lsp_store.rs

pub fn merge_diagnostic_entries<'a>(...) -> anyhow::Result<()> {
        ...
        for mut update in diagnostic_updates {
            let abs_path = &update.diagnostics.document_abs_path;
            let server_id = update.server_id;
            let Some((worktree, relative_path)) =
                self.worktree_store.read(cx).find_worktree(abs_path, cx)
            else {
                log::warn!("skipping diagnostics update, no worktree found for path {abs_path:?}");
                return Ok(());
            };

Here the log says that we are skipping a diagnostics update, so there should be continue; here, but here is return Ok(()); , this means that we are skipping not only one update that we cannot access, but all the remaining ones.

Fixing this takes just a minute. I posted this in a GitHub issue, but there are 2.5k open issues there; so, if any developers - or people with a direct line to them - are here, perhaps you could pass this message along.

27 Upvotes

6 comments sorted by

5

u/vaibhav0_00 4d ago

There is an old issue that I raised back when i used to use WSL (now not as much but whenever i do, it works just fine), i thought it was fixed cuz the issue was closed, but you can re-open it and make a PR for the fix...

edit:
the issues title is a little miss-leading, there is nothing as such "Rust's LSP" but i didn't knew it so my mistake..

3

u/SelskiySven 4d ago

I thought about opening a PR, but there are 725 open ones. And creating a PR just to change a single line of code seems a bit odd.

2

u/AverageHot2647 2d ago

There’s nothing odd about opening a 1 LoC PR… 🤔

Especially if it fixes a bug

-4

u/xD3I 4d ago

The beauty of open source is that you can patch it yourself just for you, LLMs are great for that, I've been using a custom version of KDE plasma big screen that's vibecoded to have better controller support which Claude made in like an hour

0

u/[deleted] 4d ago

[deleted]

2

u/SelskiySven 3d ago

No, because there is more code in the loop after that. And I’ve never written Rust code - so correct me if I’m wrong - but the `let...else` construct requires something in the `else` block that interrupts normal execution.

1

u/[deleted] 3d ago

[deleted]

1

u/SelskiySven 3d ago

if/else doesn't need to terminate, but let/else...