Skip to content

Commit 99fa915

Browse files
authored
Use y and n keybindings for keep- and undo-changes. (microsoft#250635)
fixes microsoft#248041 (comment)
1 parent af87ab9 commit 99fa915

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { IInstantiationService } from '../../../../../platform/instantiation/com
2222
import { ActiveEditorContext } from '../../../../common/contextkeys.js';
2323
import { EditorResourceAccessor, SideBySideEditor, TEXT_DIFF_EDITOR_ID } from '../../../../common/editor.js';
2424
import { ChatContextKeys } from '../../common/chatContextKeys.js';
25-
import { NOTEBOOK_CELL_LIST_FOCUSED } from '../../../notebook/common/notebookContextKeys.js';
25+
import { NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_EDITOR_FOCUSED } from '../../../notebook/common/notebookContextKeys.js';
2626

2727

2828
abstract class ChatEditingEditorAction extends Action2 {
@@ -176,16 +176,11 @@ abstract class KeepOrUndoAction extends ChatEditingEditorAction {
176176
: Codicon.discard,
177177
f1: true,
178178
keybinding: {
179-
when: EditorContextKeys.focus,
180-
weight: KeybindingWeight.WorkbenchContrib,
179+
when: ContextKeyExpr.or(EditorContextKeys.focus, NOTEBOOK_EDITOR_FOCUSED),
180+
weight: KeybindingWeight.WorkbenchContrib + 10, // win over new-window-action
181181
primary: _keep
182-
? KeyMod.CtrlCmd | KeyCode.Enter
183-
: KeyMod.CtrlCmd | KeyCode.Backspace,
184-
win: {
185-
primary: _keep
186-
? KeyMod.Alt | KeyCode.Enter
187-
: KeyMod.Alt | KeyCode.Backspace
188-
},
182+
? KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyY
183+
: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyN,
189184
},
190185
menu: {
191186
id: MenuId.ChatEditingEditorContent,
@@ -245,13 +240,8 @@ abstract class AcceptRejectHunkAction extends ChatEditingEditorAction {
245240
when: ContextKeyExpr.or(EditorContextKeys.focus, NOTEBOOK_CELL_LIST_FOCUSED),
246241
weight: KeybindingWeight.WorkbenchContrib + 1,
247242
primary: _accept
248-
? KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Enter
249-
: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Backspace,
250-
win: {
251-
primary: _accept
252-
? KeyMod.Alt | KeyMod.Shift | KeyCode.Enter
253-
: KeyMod.Alt | KeyMod.Shift | KeyCode.Backspace,
254-
}
243+
? KeyMod.CtrlCmd | KeyCode.KeyY
244+
: KeyMod.CtrlCmd | KeyCode.KeyN
255245
},
256246
menu: {
257247
id: MenuId.ChatEditingEditorHunk,

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { renderIcon } from '../../../../../base/browser/ui/iconLabel/iconLabels.
3232
import { ThemeIcon } from '../../../../../base/common/themables.js';
3333
import * as arrays from '../../../../../base/common/arrays.js';
3434
import { renderStringAsPlaintext } from '../../../../../base/browser/markdownRenderer.js';
35+
import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js';
3536

3637
class ChatEditorOverlayWidget extends Disposable {
3738

@@ -49,6 +50,7 @@ class ChatEditorOverlayWidget extends Disposable {
4950
constructor(
5051
private readonly _editor: { focus(): void },
5152
@IChatService private readonly _chatService: IChatService,
53+
@IKeybindingService private readonly _keybindingService: IKeybindingService,
5254
@IInstantiationService private readonly _instaService: IInstantiationService,
5355
) {
5456
super();
@@ -272,9 +274,22 @@ class ChatEditorOverlayWidget extends Disposable {
272274
that._editor.focus();
273275
});
274276
}
277+
275278
override get actionRunner(): IActionRunner {
276279
return super.actionRunner;
277280
}
281+
282+
protected override getTooltip(): string | undefined {
283+
const value = super.getTooltip();
284+
if (!value) {
285+
return value;
286+
}
287+
const kb = that._keybindingService.lookupKeybinding(this.action.id);
288+
if (!kb) {
289+
return value;
290+
}
291+
return localize('tooltip', "{0} ({1})", value, kb.getLabel());
292+
}
278293
};
279294
}
280295

0 commit comments

Comments
 (0)