Skip to content

Commit 5f330d3

Browse files
authored
Fix sort order of chat variables in quick pick (#216773)
1 parent 8aee206 commit 5f330d3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatContextActions.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { ISymbolQuickPickItem, SymbolsQuickAccessProvider } from 'vs/workbench/c
3232
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
3333
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
3434
import { EditorType } from 'vs/editor/common/editorCommon';
35+
import { compare } from 'vs/base/common/strings';
3536

3637
export function registerChatContextActions() {
3738
registerAction2(AttachContextAction);
@@ -287,7 +288,21 @@ class AttachContextAction extends Action2 {
287288
prefix: SymbolsQuickAccessProvider.PREFIX
288289
});
289290

290-
this._show(quickInputService, commandService, widget, quickPickItems);
291+
function extractTextFromIconLabel(label: string | undefined): string {
292+
if (!label) {
293+
return '';
294+
}
295+
const match = label.match(/\$\([^\)]+\)\s*(.+)/);
296+
return match ? match[1] : label;
297+
}
298+
299+
this._show(quickInputService, commandService, widget, quickPickItems.sort(function (a, b) {
300+
301+
const first = extractTextFromIconLabel(a.label).toUpperCase();
302+
const second = extractTextFromIconLabel(b.label).toUpperCase();
303+
304+
return compare(first, second);
305+
}));
291306
}
292307

293308
private _show(quickInputService: IQuickInputService, commandService: ICommandService, widget: IChatWidget, quickPickItems: (IChatContextQuickPickItem | QuickPickItem)[], query: string = '') {

0 commit comments

Comments
 (0)