-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix preserveSourceNewlines sibling node comparison (fixes extra newli…
…nes in organize imports) (#42630) * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * Update package-lock.json * More sophisticated check for source position comparability * Fix organize imports by looking at the nodes positions * Rollback formatting changes * Added tests, fixed organizeImports algorithm * Fix autoformatting again * Make sibling node comparison work for all lists * Don’t run siblingNodePositionsAreComparable at all unless `preserveSourceNewlines` is true * Move getNodeAtPosition back * Optimize * Use node array index check instead of tree walk * Revert unneeded change Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com> Co-authored-by: Armando Aguirre <armanio123@outlook.com>
- Loading branch information
1 parent
68b0323
commit 3c32f6e
Showing
5 changed files
with
164 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// Regression test for bug #41417 | ||
|
||
//// import { | ||
//// d, d as D, | ||
//// c, | ||
//// c as C, b, | ||
//// b as B, a | ||
//// } from './foo'; | ||
//// import { | ||
//// h, h as H, | ||
//// g, | ||
//// g as G, f, | ||
//// f as F, e | ||
//// } from './foo'; | ||
//// | ||
//// console.log(a, B, b, c, C, d, D); | ||
//// console.log(e, f, F, g, G, H, h); | ||
|
||
verify.organizeImports( | ||
`import { | ||
a, b, | ||
b as B, c, | ||
c as C, d, d as D, e, f, | ||
f as F, g, | ||
g as G, h, h as H | ||
} from './foo'; | ||
console.log(a, B, b, c, C, d, D); | ||
console.log(e, f, F, g, G, H, h);` | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// Regression test for bug #41417 | ||
|
||
//// import { | ||
//// Foo | ||
//// , Bar | ||
//// } from "foo" | ||
//// | ||
//// console.log(Foo, Bar); | ||
|
||
verify.organizeImports( | ||
`import { Bar, Foo } from "foo"; | ||
console.log(Foo, Bar);` | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// Regression test for bug #41417 | ||
|
||
//// import { | ||
//// Bar | ||
//// , Foo | ||
//// } from "foo" | ||
//// | ||
//// console.log(Foo, Bar); | ||
|
||
verify.organizeImports( | ||
`import { | ||
Bar, | ||
Foo | ||
} from "foo"; | ||
console.log(Foo, Bar);`); |