This repository was archived by the owner on Aug 30, 2025. It is now read-only.
Guard against new positions with line or char less than 1 - #800
Open
zachallaun wants to merge 1 commit into
Open
Guard against new positions with line or char less than 1#800zachallaun wants to merge 1 commit into
zachallaun wants to merge 1 commit into
Conversation
scohen
approved these changes
Jul 26, 2024
scohen
left a comment
Collaborator
There was a problem hiding this comment.
This will have the temporary effect of making lexical more likely-ish to crash. We should merge this post 0.7 release
Collaborator
Author
|
Agreed; added to 0.8 milestone. |
zachallaun
force-pushed
the
za-strict-positions
branch
from
July 28, 2024 16:34
80b5cf1 to
99285e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a report in the Elixir Language Discord of an error that occurred during a completion:
This can only occur when a
Lexical.Document.Positionis created with:characterset to 0. There is therefore an implicit invariant that any positions intended to be sent in a response have a positive character.This PR makes that invariant explicit by adding a guard to
Position.new/3that will raise of any line/character that is not greater-than-or-equal-to 1.There were a few places where we were using "utility positions" with line and/or character set to 0, but as far as I can tell, replacing these cases with line/character 1 does not change any behavior.
It is likely that there are still position-related bugs in Lexical, but this should help us catch them closer to where the bug is instead of during conversion to LSP where the stacktrace is pretty useless.