Commit bfc2fbf
committed
fix: Ensure specifier sorting works with disableImportRemovalOnOrganize
Fixed critical bug where specifier sorting was skipped when
disableImportRemovalOnOrganize was enabled. Specifier sorting
must be independent from both import sorting AND import removal.
Root cause:
- When disableImportRemovalOnOrganize: true in modern mode,
code at line 548-550 preserved imports exactly as-is
- This skipped specifier sorting entirely
- Legacy mode correctly sorted specifiers at line 543
The fix:
- Always sort specifiers when disableImportRemovalOnOrganize: true
- In legacy mode: Strip isTypeOnly from individual specifiers
- In modern mode: Preserve isTypeOnly modifiers
- Specifier sorting is now truly independent from import sorting
Test fixes:
- Fixed type-only-imports-comparison.test.ts expectations
- Test expected unsorted specifiers but extension correctly sorts them
- 'createUser, type User' is correct (alphabetical: c before U)
- Updated expected output to match correct behavior
All tests passing:
- Main extension: 350 passing
- Comparison tests: 208 passing
This ensures consistent behavior where specifiers are ALWAYS sorted
alphabetically, regardless of disableImportsSorting or
disableImportRemovalOnOrganize settings.1 parent eb7bd94 commit bfc2fbf
3 files changed
Lines changed: 24 additions & 22 deletions
File tree
- .claude
- comparison-test-harness/test-cases
- src/imports
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
| 77 | + | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
| 131 | + | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
| 156 | + | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
552 | 551 | | |
553 | 552 | | |
554 | 553 | | |
| |||
0 commit comments