fix(intellisense): clamp spell-check start line with Math.max - #407
Open
RobertoReale wants to merge 1 commit into
Open
fix(intellisense): clamp spell-check start line with Math.max#407RobertoReale wants to merge 1 commit into
RobertoReale wants to merge 1 commit into
Conversation
`Math.min(0, line-1)` is always <= 0, so any edit on line 0 (and every edit whose start line is 0) builds a Range starting at line -1 and VS Code throws `Illegal argument: line must be non-negative`. The intent is clearly to look one line back without going below 0, i.e. `Math.max`.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #402
Problem
MisspellingCheckProvidercomputes the first line to re-check as:Math.min(0, x)is always<= 0, so:startLine = -1, and thevscode.Rangeconstructor throwsIllegal argument: line must be non-negativebeforevalidateRangegets a chance to clamp it;startLine = 0, so the whole document from line 0 up to the edited line is re-checked instead of the intended one line of context.The handler is an unawaited
asynccallback, so the exception also shows up asrejected promise not handled within 1 second(visible in the logs attached to #194).Change
Math.min→Math.max, which is what the surrounding code intends: one line of context, clamped at the start of the document.