Skip to content

fix(#323): widen parser-error range to offending token length#377

Open
kreinba wants to merge 1 commit into
objectionary:masterfrom
kreinba:323
Open

fix(#323): widen parser-error range to offending token length#377
kreinba wants to merge 1 commit into
objectionary:masterfrom
kreinba:323

Conversation

@kreinba

@kreinba kreinba commented Jun 20, 2026

Copy link
Copy Markdown

This addresses #323. The diagnostics loop in validateTextDocument built a Range whose end matched start, 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.syntaxError from the ANTLR symbol when one is supplied, falls back to one character when ANTLR omits the symbol, and threads that length through ParserError so the diagnostic Range ends at column + length. Clients now paint a real squiggle on every parser error instead of a hidden caret.

make runs end to end on the branch: parser generation, tsc -b, ncc bundle, 40 jest tests at 100 percent statement and 100 percent branch coverage on errorListener.ts, and eslint src --ext .ts clean. A new test in test/parser.test.ts pins that every ParserError carries a length of at least one, and a unit test exercises the symbol === undefined fallback path.

Closes #323

…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.
@kreinba

kreinba commented Jun 20, 2026

Copy link
Copy Markdown
Author

make (22.x) is red on the same Eo.g4 404 that blocks every other open PR (issue #352, fix in #367). The other eight workflows are green and the diff is independent of the grammar vendoring, so this should turn green automatically once #367 lands.

@Thayorns Thayorns left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yegor256 This PR can be merged once build is up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parser-error diagnostic emits zero-length Range; clients drop the squiggle

3 participants