Track and report position of first parse error - #1019
Open
Wilfred wants to merge 2 commits into
Open
Conversation
Wilfred
force-pushed
the
claude/parse-error-display-text-zxql1x
branch
from
July 23, 2026 23:21
8d27095 to
8860a73
Compare
Convert the tuple struct to a struct with a named `error_count` field, so that further parse error metadata can be added without relying on positional access. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JmVJsk7qNYW1UQ5Fkz8zGW
When difftastic falls back to a line-oriented diff because the parse
error limit was exceeded, append the line and column of the first parse
error to the header, e.g.:
Text (2 JavaScript parse errors, exceeded DFT_PARSE_ERROR_LIMIT, first at 3:1)
The position is captured during the initial walk of the tree-sitter AST
via a new ParseErrors accumulator, rather than walking the tree a second
time. Columns are zero-indexed and the line is a LineNumber.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JmVJsk7qNYW1UQ5Fkz8zGW
Wilfred
force-pushed
the
claude/parse-error-display-text-zxql1x
branch
from
July 28, 2026 08:51
8860a73 to
b76e9fb
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 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.
Summary
Enhanced parse error reporting to include the line and column position of the first parse error encountered, in addition to the total error count. This helps users quickly locate syntax issues in their files.
Key Changes
New
ParseErrorsstruct: Replaces simpleusizeerror count with a structured type that tracks both the total error count and the position of the first error node encounteredrecord()method to capture error positions while walking the tree-sitter ASTDefaultandClonefor convenienceUpdated
ExceededParseErrorLimiterror type: Changed from a tuple struct holding just the error count to a struct with named fields:error_count: usize- total number of parse errorsfirst_error_pos: Option<(LineNumber, usize)>- line number and zero-indexed column of first errorError tracking throughout parsing: Updated all parsing functions (
to_syntax,to_syntax_with_limit,syntax_from_cursor, etc.) to use the newParseErrorsstruct instead of a simple counterEnhanced user-facing error messages: When parse error limit is exceeded, the error message now includes the position of the first error (e.g., "first at 5:6")
Documentation update: Updated manual to reflect the new error position reporting in the output example
Implementation Details
ParseErrors::record()method only captures the position of the first error encountered, avoiding unnecessary overhead for subsequent errorsLineNumbertype from theline_numberscratehttps://claude.ai/code/session_01JmVJsk7qNYW1UQ5Fkz8zGW