Skip to content

Commit 729a499

Browse files
authored
QuickPick - fix sorting when label contains an icon (microsoft#153475)
* Fix label sorting when the label contains icons * Rename property
1 parent 3134110 commit 729a499

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/vs/base/parts/quickinput/browser/quickInputList.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ interface IListElement {
3535
readonly index: number;
3636
readonly item: IQuickPickItem;
3737
readonly saneLabel: string;
38+
readonly saneSortLabel: string;
3839
readonly saneMeta?: string;
3940
readonly saneAriaLabel: string;
4041
readonly saneDescription?: string;
@@ -52,6 +53,7 @@ class ListElement implements IListElement, IDisposable {
5253
index!: number;
5354
item!: IQuickPickItem;
5455
saneLabel!: string;
56+
saneSortLabel!: string;
5557
saneMeta!: string;
5658
saneAriaLabel!: string;
5759
saneDescription?: string;
@@ -440,6 +442,7 @@ export class QuickInputList {
440442
if (item.type !== 'separator') {
441443
const previous = index && inputElements[index - 1];
442444
const saneLabel = item.label && item.label.replace(/\r?\n/g, ' ');
445+
const saneSortLabel = parseLabelWithIcons(saneLabel).text.trim();
443446
const saneMeta = item.meta && item.meta.replace(/\r?\n/g, ' ');
444447
const saneDescription = item.description && item.description.replace(/\r?\n/g, ' ');
445448
const saneDetail = item.detail && item.detail.replace(/\r?\n/g, ' ');
@@ -454,6 +457,7 @@ export class QuickInputList {
454457
index,
455458
item,
456459
saneLabel,
460+
saneSortLabel,
457461
saneMeta,
458462
saneAriaLabel,
459463
saneDescription,
@@ -738,7 +742,7 @@ function compareEntries(elementA: ListElement, elementB: ListElement, lookFor: s
738742
return 0;
739743
}
740744

741-
return compareAnything(elementA.saneLabel, elementB.saneLabel, lookFor);
745+
return compareAnything(elementA.saneSortLabel, elementB.saneSortLabel, lookFor);
742746
}
743747

744748
class QuickInputAccessibilityProvider implements IListAccessibilityProvider<ListElement> {

0 commit comments

Comments
 (0)