Repository navigation
Preserve formatter alignment across tabs and enum decorators - #65463
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
Mixed leading whitespace must advance to the next tab stop so multiline comments retain their relative indentation when formatting changes the surrounding block indentation. Match the enum keyword after decorators so partially written declarations stay aligned instead of gaining an extra indentation level.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the tab-stop and decorator indentation changes.
No open issues 🎉
What changed in this PR
This PR fixes indentation handling in the native TypeScript formatter so mixed whitespace and decorators do not disrupt alignment during editing.
Changes:
- Advances tabs to the next tab stop, preserving multiline comments’ relative indentation.
- Matches the enum keyword after decorators to avoid an extra indentation level.
- Adds fourslash regression tests for both cases.
| File | Description |
|---|---|
tsc/internal/fourslash/tests/formattingMultilineCommentsWithTabs1_test.go |
Tests multiline comment alignment with mixed spaces and tabs. |
tsc/internal/fourslash/tests/formattingDecorators_test.go |
Tests enum alignment when an invalid decorator is present. |
tsc/internal/format/span.go |
Uses the enum keyword token for alignment after decorators. |
tsc/internal/format/indent.go |
Corrects tab-stop column calculation. |
Review effort: Balanced
This branch has not been deployed
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.
Mixed leading whitespace must advance to the next tab stop so multiline comments retain their relative indentation when formatting changes the surrounding block indentation.
Match the enum keyword after decorators so partially written declarations stay aligned instead of gaining an extra indentation level.