Skip to content

Commit a65d762

Browse files
committed
Adopt Intl.Collator for SortLinesCommand (microsoft#70920)
1 parent 1cb4575 commit a65d762

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/vs/editor/contrib/linesOperations/sortLinesCommand.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/mod
1111

1212
export class SortLinesCommand implements editorCommon.ICommand {
1313

14+
private static _COLLATOR: Intl.Collator | null = null;
15+
public static getCollator(): Intl.Collator {
16+
if (!SortLinesCommand._COLLATOR) {
17+
SortLinesCommand._COLLATOR = new Intl.Collator();
18+
}
19+
return SortLinesCommand._COLLATOR;
20+
}
21+
1422
private readonly selection: Selection;
1523
private readonly descending: boolean;
1624
private selectionId: string | null;
@@ -76,9 +84,7 @@ function getSortData(model: ITextModel, selection: Selection, descending: boolea
7684
}
7785

7886
let sorted = linesToSort.slice(0);
79-
sorted.sort((a, b) => {
80-
return a.toLowerCase().localeCompare(b.toLowerCase());
81-
});
87+
sorted.sort(SortLinesCommand.getCollator().compare);
8288

8389
// If descending, reverse the order.
8490
if (descending === true) {

0 commit comments

Comments
 (0)