Skip to content

Commit fc72077

Browse files
authored
Merge pull request microsoft#210270 from microsoft/roblou/nosy-emu
Add keybinding for chat 'cancel'
2 parents ee83577 + b4a33b8 commit fc72077

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,26 @@ export class CancelAction extends Action2 {
157157
id: MenuId.ChatExecute,
158158
when: CONTEXT_CHAT_REQUEST_IN_PROGRESS,
159159
group: 'navigation',
160+
},
161+
keybinding: {
162+
weight: KeybindingWeight.WorkbenchContrib,
163+
primary: KeyMod.CtrlCmd | KeyCode.Escape,
160164
}
161165
});
162166
}
163167

164168
run(accessor: ServicesAccessor, ...args: any[]) {
165-
const context: IChatExecuteActionContext = args[0];
166-
if (!context.widget) {
169+
const context: IChatExecuteActionContext | undefined = args[0];
170+
171+
const widgetService = accessor.get(IChatWidgetService);
172+
const widget = context?.widget ?? widgetService.lastFocusedWidget;
173+
if (!widget) {
167174
return;
168175
}
169176

170177
const chatService = accessor.get(IChatService);
171-
if (context.widget.viewModel) {
172-
chatService.cancelCurrentRequestForSession(context.widget.viewModel.sessionId);
178+
if (widget.viewModel) {
179+
chatService.cancelCurrentRequestForSession(widget.viewModel.sessionId);
173180
}
174181
}
175182
}

0 commit comments

Comments
 (0)