Skip to content

Commit 6d0933c

Browse files
authored
Clear chat with cmd/ctrl+N (microsoft#252092)
And New Chat Editor when the editor is focused Fix microsoft/vscode-copilot-release#8110
1 parent 8808f0b commit 6d0933c

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,12 @@ export function registerChatActions() {
476476
title: localize2('interactiveSession.open', "New Chat Editor"),
477477
f1: true,
478478
category: CHAT_CATEGORY,
479-
precondition: ChatContextKeys.enabled
479+
precondition: ChatContextKeys.enabled,
480+
keybinding: {
481+
weight: KeybindingWeight.WorkbenchContrib + 1,
482+
primary: KeyMod.CtrlCmd | KeyCode.KeyN,
483+
when: ContextKeyExpr.and(ChatContextKeys.inChatSession, ChatContextKeys.inChatEditor)
484+
}
480485
});
481486
}
482487

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ export function registerNewChatActions() {
8484
order: -1
8585
}],
8686
keybinding: {
87-
weight: KeybindingWeight.WorkbenchContrib,
88-
primary: KeyMod.CtrlCmd | KeyCode.KeyL,
87+
weight: KeybindingWeight.WorkbenchContrib + 1,
88+
primary: KeyMod.CtrlCmd | KeyCode.KeyN,
89+
secondary: [KeyMod.CtrlCmd | KeyCode.KeyL],
8990
mac: {
90-
primary: KeyMod.WinCtrl | KeyCode.KeyL
91+
primary: KeyMod.CtrlCmd | KeyCode.KeyN,
92+
secondary: [KeyMod.WinCtrl | KeyCode.KeyL]
9193
},
9294
when: ChatContextKeys.inChatSession
9395
}

src/vs/workbench/contrib/chat/browser/chatEditor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { IEditorOpenContext } from '../../../common/editor.js';
1818
import { Memento } from '../../../common/memento.js';
1919
import { EDITOR_DRAG_AND_DROP_BACKGROUND } from '../../../common/theme.js';
2020
import { IEditorGroup } from '../../../services/editor/common/editorGroupsService.js';
21+
import { ChatContextKeys } from '../common/chatContextKeys.js';
2122
import { IChatModel, IExportableChatData, ISerializableChatData } from '../common/chatModel.js';
2223
import { CHAT_PROVIDER_ID } from '../common/chatParticipantContribTypes.js';
2324
import { ChatAgentLocation, ChatMode } from '../common/constants.js';
@@ -60,6 +61,7 @@ export class ChatEditor extends EditorPane {
6061
protected override createEditor(parent: HTMLElement): void {
6162
this._scopedContextKeyService = this._register(this.contextKeyService.createScoped(parent));
6263
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));
64+
ChatContextKeys.inChatEditor.bindTo(this._scopedContextKeyService).set(true);
6365

6466
this.widget = this._register(
6567
scopedInstantiationService.createInstance(

src/vs/workbench/contrib/chat/common/chatContextKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export namespace ChatContextKeys {
3131
export const inputHasFocus = new RawContextKey<boolean>('chatInputHasFocus', false, { type: 'boolean', description: localize('interactiveInputHasFocus', "True when the chat input has focus.") });
3232
export const inChatInput = new RawContextKey<boolean>('inChatInput', false, { type: 'boolean', description: localize('inInteractiveInput', "True when focus is in the chat input, false otherwise.") });
3333
export const inChatSession = new RawContextKey<boolean>('inChat', false, { type: 'boolean', description: localize('inChat', "True when focus is in the chat widget, false otherwise.") });
34+
export const inChatEditor = new RawContextKey<boolean>('inChatEditor', false, { type: 'boolean', description: localize('inChatEditor', "Whether focus is in a chat editor.") });
3435
export const hasPromptFile = new RawContextKey<boolean>('chatPromptFileAttached', false, { type: 'boolean', description: localize('chatPromptFileAttachedContextDescription', "True when the chat has a prompt file attached.") });
3536
export const chatMode = new RawContextKey<ChatMode>('chatMode', ChatMode.Ask, { type: 'string', description: localize('chatMode', "The current chat mode.") });
3637

0 commit comments

Comments
 (0)