-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
robustly handle invalid LSP ranges #6512
Conversation
4b5f548
to
0c4b15e
Compare
0c4b15e
to
a402e2a
Compare
// If it extends past the end, truncate it to the end. This is because the | ||
// way the LSP describes the range including the last newline is by | ||
// specifying a line number after what we would call the last line. | ||
log::warn!("LSP position {pos:?} out of range assuming EOF"); | ||
return Some(doc.len_chars()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is #6022, right? And this change brings us in line with VSCode's handling of this edge-case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly vscode behaves the same and the comment is from neovim so they also behave the same
a402e2a
to
799075a
Compare
offset_encoding: OffsetEncoding, | ||
) -> Option<Range> { | ||
// This is sort of an edgecase. It's not clear from the spec how to deal with | ||
// ranges where end < start. They don't make much sense but vscode simply caps start to end | ||
// and because it's not specified quite a few LS rely on this as a result (for example the TS server) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(╯°□°)╯︵ ┻━┻
Fix crashes with the TS language server reported on matrix
The Problem is that the way helix deals with invalid LSP ranges is different from other editors right now. Helix currently panics if the start of a LSP range is after the end of the range. The standard doesn't actually state that this is forbidden. VSCode simply sets
start=end
in that case and there seem to be a few servers relying on this sadly. I matched that behavior but logged an error to make sure this is not missed when tracking down issues. Alternatively we could discard such ranges. We definitely shouldn't panic tough.Similarly, we now allow ranges with line numbers past the end (simply treated as EOF). VSCode behaves the same and so does neovim. I copied their comment here: