-
Notifications
You must be signed in to change notification settings - Fork 747
Fix multiline ternary expression formatting with tabs #2203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jakebailey <[email protected]>
When indentation is -1 (Unknown), prevent arithmetic operations that produce invalid indentation values. This fixes the issue where multiline ternary expressions with tabs were being formatted with mixed tabs and spaces. Co-authored-by: jakebailey <[email protected]>
|
@copilot You forgot to run test/format/lint/etc |
- Format code with dprint - Use Go 1.22+ integer range syntax in for loops Co-authored-by: jakebailey <[email protected]>
internal/format/ternary_test.go
Outdated
| "github.com/microsoft/typescript-go/internal/parser" | ||
| ) | ||
|
|
||
| func TestTernaryWithTabs(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot just put this in internal/format/format_test.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in cbc5012. Moved the test to format_test.go.
internal/format/ternary_test.go
Outdated
| // Check that we don't have mixed tabs and spaces | ||
| // The formatted text should only use tabs for indentation | ||
| lines := splitLines(newText) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Just assert a specific output string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in cbc5012. Changed to assert the specific expected output string.
- Moved TestTernaryWithTabs from ternary_test.go to format_test.go - Changed test to assert specific expected output string - Removed ternary_test.go file Co-authored-by: jakebailey <[email protected]>
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.