fix(#323): widen parser-error range to offending token length#377
Open
kreinba wants to merge 1 commit into
Open
fix(#323): widen parser-error range to offending token length#377kreinba wants to merge 1 commit into
kreinba wants to merge 1 commit into
Conversation
…ngth The diagnostics loop in validateTextDocument built a Range whose end matched start, producing zero-length squiggles that VSCode renders as an invisible caret and that some other LSP clients drop entirely. ErrorListener.syntaxError now derives the offending token's length from the ANTLR symbol when present, falls back to one when ANTLR omits the symbol, and threads that length through ParserError so the diagnostic Range ends at column + length and clients render a real squiggle on every error.
Author
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.
This addresses #323. The diagnostics loop in
validateTextDocumentbuilt a Range whoseendmatchedstart, which produced zero-length squiggles that VSCode renders as an invisible caret and that some other LSP clients drop entirely.The fix derives the offending token's length inside
ErrorListener.syntaxErrorfrom the ANTLR symbol when one is supplied, falls back to one character when ANTLR omits the symbol, and threads that length throughParserErrorso the diagnostic Range ends atcolumn + length. Clients now paint a real squiggle on every parser error instead of a hidden caret.makeruns end to end on the branch: parser generation,tsc -b,nccbundle, 40 jest tests at 100 percent statement and 100 percent branch coverage onerrorListener.ts, andeslint src --ext .tsclean. A new test intest/parser.test.tspins that everyParserErrorcarries a length of at least one, and a unit test exercises thesymbol === undefinedfallback path.Closes #323