Skip to content

Commit a51c2a3

Browse files
committed
handle cmd modifier in the prompt selection dialog
1 parent 7427529 commit a51c2a3

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class AttachPromptAction extends Action2 {
6464
promptFiles,
6565
labelService,
6666
viewsService,
67+
openerService,
6768
quickInputService,
6869
});
6970
}

src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { DisposableStore } from '../../../../../../../base/common/lifecycle.js';
1313
import { dirname, extUri } from '../../../../../../../base/common/resources.js';
1414
import { isLinux, isWindows } from '../../../../../../../base/common/platform.js';
1515
import { ILabelService } from '../../../../../../../platform/label/common/label.js';
16+
import { IOpenerService } from '../../../../../../../platform/opener/common/opener.js';
1617
import { IViewsService } from '../../../../../../services/views/common/viewsService.js';
1718
import { assertDefined, WithUriValue } from '../../../../../../../base/common/types.js';
1819
import { getCleanPromptName } from '../../../../../../../platform/prompts/common/constants.js';
@@ -45,6 +46,7 @@ export interface ISelectPromptOptions {
4546

4647
readonly labelService: ILabelService;
4748
readonly viewsService: IViewsService;
49+
readonly openerService: IOpenerService;
4850
readonly quickInputService: IQuickInputService;
4951
}
5052

@@ -100,7 +102,7 @@ export const askToSelectPrompt = async (
100102
}
101103

102104
// otherwise show the prompt file selection dialog
103-
const { viewsService } = options;
105+
const { viewsService, openerService } = options;
104106

105107
const quickPick = quickInputService.createQuickPick<WithUriValue<IQuickPickItem>>();
106108
quickPick.activeItems = activeItem ? [activeItem] : [];
@@ -124,9 +126,27 @@ export const askToSelectPrompt = async (
124126
});
125127

126128
disposables.add(quickPick.onDidAccept(async (event) => {
129+
const { alt, ctrlCmd } = quickPick.keyMods;
130+
131+
// TODO: @lego - refactor?
132+
// if `cmd`/`ctrl` key was pressed, open the selected prompt file(s)
133+
if (ctrlCmd) {
134+
for (const selectedItem of quickPick.selectedItems) {
135+
await openerService.open(selectedItem.value);
136+
}
137+
138+
// if user submitted their selection, close the dialog
139+
if (!event.inBackground) {
140+
disposables.dispose();
141+
}
142+
143+
return;
144+
}
145+
146+
// otherwise attach the selected prompt to a chat input
127147
lastActiveWidget = await getChatWidgetObject(
128148
options,
129-
quickPick.keyMods.alt,
149+
alt,
130150
viewsService,
131151
);
132152

@@ -139,7 +159,7 @@ export const askToSelectPrompt = async (
139159

140160
// if user submitted their selection, close the dialog
141161
if (!event.inBackground) {
142-
return disposables.dispose();
162+
disposables.dispose();
143163
}
144164
}));
145165

0 commit comments

Comments
 (0)