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

Filter out language servers which fail to spawn #8374

Merged
merged 3 commits into from Sep 26, 2023

Conversation

woojiq
Copy link
Contributor

@woojiq woojiq commented Sep 24, 2023

Return Result<Arc<Client>> instead of Arc<Client> so that we can then filter only successfully started language servers and create an error log otherwise.

Closes #8361

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently nice and minimal but I think we should do a slightly larger refactor here since Registry::get is forcing us to collect twice and it's making the call site in Editor awkward. (Although the Option handling there is also awkward, so I say let's fix that in this patch too.)

Let's make Registry::get return an impl Iterator<Item = (LanguageServerName, Result<Arc<Client>>)>. Then when launching the language servers we can filter out the Errs as you already do in this patch, collect into the HashMap, and return early when language_servers is empty.

That launch_language_servers function is returning Option<()> and bubbling it up to refresh_language_servers but the return value is never used. I think the option is very confusing - I don't really understand the distinction between Some(()) and None - so let's remove those return types on refresh_language_servers and launch_language_servers. Each of the ? operators can be replaced with let Some(..) = .. else { return };s

@the-mikedavis the-mikedavis added C-bug Category: This is a bug A-language-server Area: Language server client S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 24, 2023
@woojiq
Copy link
Contributor Author

woojiq commented Sep 25, 2023

Done, thanks for the suggestion to return an iterator instead of collecting twice) The diff is a bit crazy because I moved the if content outside, so it looks like I overwrote everything.
We needed to unify all lifetimes in get so that we can use move in the closure (without move - error that closure will outlive borrowed enable_snippets) and also to return the iterator.

the-mikedavis
the-mikedavis previously approved these changes Sep 25, 2023
@the-mikedavis the-mikedavis added S-waiting-on-review Status: Awaiting review from a maintainer. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 25, 2023
Copy link
Member

@pascalkuthe pascalkuthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great, thnaks for working on this! I agree this should land before the release. This is also a nice cleanup.

I found one minor nit, otherwise this LGTM

Comment on lines 775 to 780
Ok(client) => client,
Err(err) => return (name.to_owned(), Err(err)),
};
let clients = self.inner.entry(name.clone()).or_default();
clients.push(client.clone());
Ok((name.clone(), client))
})
.collect()
(name.clone(), Ok(client))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instead of the early return I think it would be cleaner to just move the last 3 lines into the Ok match arm

@woojiq
Copy link
Contributor Author

woojiq commented Sep 26, 2023

Done.

Off-topic: Do I need to write comments like "Done" after the suggested changes? Do you get notified about new commits of reviewed code? Iirc, I was notified, so these comments are redundant.

Copy link
Member

@pascalkuthe pascalkuthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't have to write it, I get GitHub notifications when somebody pushes to a PR. In cases like this where its just a small change missing before merge I would check myself (but it doesn't hurt if you leave the comment either). For larger PRs ts nice if you do leave some comments, a push may not necessarily indicate they are done and I often skip those notifications (since I get a lot of those).

@the-mikedavis the-mikedavis changed the title fix: all lsp terminates if at least one failed to start Filter out language servers which fail to spawn Sep 26, 2023
@the-mikedavis the-mikedavis merged commit 080a085 into helix-editor:master Sep 26, 2023
6 checks passed
@woojiq woojiq deleted the fix-multiple-lsp branch September 26, 2023 20:32
acristoffers pushed a commit to acristoffers/helix that referenced this pull request Nov 18, 2023
danillos pushed a commit to danillos/helix that referenced this pull request Nov 21, 2023
dgkf pushed a commit to dgkf/helix that referenced this pull request Jan 30, 2024
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 S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Language servers fail if one is missing
3 participants