Repository navigation
Report indentation from Format Document's layout, so a diagnostic always matches what formatting does - #397
Merged
Merged
Conversation
Contributor
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 35 seconds. View limit details
|
jbearak
force-pushed
the
refactor/indentation-from-formatter
branch
2 times, most recently
from
November 6, 2026 00:11
f5609a3 to
f294cd6
Compare
…ays matches what formatting does The indentation diagnostics computed each line's expected depth with their own AST walks, a raw brace scan, and a comment heuristic, while the formatter computed its own layout, and the two disagreed: across Stata's 3,780 base ados, 9,360 indentation diagnostics survived Format Document, which the messages tell the user to run. A line is now reported exactly when source-preserving Format Document would re-indent it (UNNECESSARY_INDENTATION when less, MISSING_INDENTATION when more). Comment-only lines and lines inside block comments stay exempt, and structural parse errors still suppress their block. The analyzer's own walkers (about 650 lines) are gone; its tests now go through analyze() on real documents. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…acing inside it Co-Authored-By: Claude Opus 5.5 <[email protected]>
jbearak
force-pushed
the
refactor/indentation-from-formatter
branch
from
November 6, 2026 00:18
f294cd6 to
716ce4e
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.
Indentation diagnostics tell the user to "Use Format Document to fix", but they computed expected indentation separately from the formatter, with their own AST walks, a raw brace scan, and a comment heuristic, and the two disagreed. Across Stata's 3,780 base ados, formatting every file still left 9,360 indentation diagnostics in 349 files.
Decision: the default source-preserving formatter is the authority. A code line is reported when Format Document (source-preserving) would re-indent it:
MISSING_INDENTATIONwhen it would indent the line more,UNNECESSARY_INDENTATIONwhen less. Kept from before:The analyzer's own layout code (about 650 lines) is gone. Its tests now go through
analyze()on real documents; tests of deleted internals and fakeast: nulldocuments moved to a shared helper,expect_line_at_depth.Behaviour changes worth knowing:
/* */and///continuations./* c */ display 1is reported when Format Document moves it; it used to be exempt. Lines whose inner spacing Format Document also changes (display\t1) are still checked.Proof: after Format Document, 34 indentation diagnostics remain across 11 of 3,803 files, down from 9,360 in 349 files. The 34 are places where formatting twice changes more, which is a separate formatter idempotence issue. Timing is 35 ms on an 11,000-line ado. Typecheck, lint, and
bun test ./testspass (9642 tests).Reviewed with sol-loop: 2 rounds with gpt-6.1-sol. Sol verdict: approved
Created with Claude Opus 5.5 in T3 Code.