typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Fix multiline ternary expression formatting with tabs

Open Copilot opened this issue 3 weeks ago • 2 comments

  • [x] Understand the issue: multiline ternary expressions with tabs are being formatted with mixed tabs and spaces
  • [x] Create a test to reproduce the issue
  • [x] Investigate the root cause in the indentation calculation logic
  • [x] Fix the indentation calculation for conditional expression branches
  • [x] Verify the fix with the test
  • [x] Run all format tests to ensure no regressions
  • [x] Clean up accidental patch files
  • [x] Run format, lint, and test commands
  • [x] Move test to format_test.go and assert specific output
Original prompt

This section details on the original issue you should resolve

<issue_title>Bad formatting of multiline ternary expression</issue_title> <issue_description>From https://github.com/microsoft/TypeScript/issues/14494 (original issue was actually fixed in 6, but regressed here)

Format the following code that uses tabs for indentation :

const test = (a: string) => (
	a === '1' ? (
		10
	) : (
		12
	)
)

Bug You get a mix of tabs and spaces:

const test = (a: string) => (
	a === '1' ? (
   10
	) : (
   12
	)
)
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

  • Fixes microsoft/typescript-go#2201

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot avatar Dec 03 '25 21:12 Copilot