Skip to content

Commit 3413ae9

Browse files
authored
debt - extract action ids into constants (microsoft#234079)
1 parent 4bfa2f8 commit 3413ae9

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,9 @@ abstract class NavigateAction extends Action2 {
110110

111111
abstract class AcceptDiscardAction extends Action2 {
112112

113-
constructor(readonly accept: boolean) {
113+
constructor(id: string, readonly accept: boolean) {
114114
super({
115-
id: accept
116-
? 'chatEditor.action.accept'
117-
: 'chatEditor.action.reject',
115+
id,
118116
title: accept
119117
? localize2('accept', 'Accept Chat Edit')
120118
: localize2('discard', 'Discard Chat Edit'),
@@ -168,6 +166,24 @@ abstract class AcceptDiscardAction extends Action2 {
168166
}
169167
}
170168

169+
export class AcceptAction extends AcceptDiscardAction {
170+
171+
static readonly ID = 'chatEditor.action.accept';
172+
173+
constructor() {
174+
super(AcceptAction.ID, true);
175+
}
176+
}
177+
178+
export class RejectAction extends AcceptDiscardAction {
179+
180+
static readonly ID = 'chatEditor.action.reject';
181+
182+
constructor() {
183+
super(RejectAction.ID, false);
184+
}
185+
}
186+
171187
class UndoHunkAction extends EditorAction2 {
172188
constructor() {
173189
super({
@@ -218,8 +234,8 @@ class OpenDiffFromHunkAction extends EditorAction2 {
218234
export function registerChatEditorActions() {
219235
registerAction2(class NextAction extends NavigateAction { constructor() { super(true); } });
220236
registerAction2(class PrevAction extends NavigateAction { constructor() { super(false); } });
221-
registerAction2(class AcceptAction extends AcceptDiscardAction { constructor() { super(true); } });
222-
registerAction2(class RejectAction extends AcceptDiscardAction { constructor() { super(false); } });
237+
registerAction2(AcceptAction);
238+
registerAction2(RejectAction);
223239
registerAction2(UndoHunkAction);
224240
registerAction2(OpenDiffFromHunkAction);
225241
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { assertType } from '../../../../base/common/types.js';
2626
import { localize } from '../../../../nls.js';
2727
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
2828
import { ctxNotebookHasEditorModification } from '../../notebook/browser/chatEdit/notebookChatEditController.js';
29+
import { AcceptAction, RejectAction } from './chatEditorActions.js';
2930

3031
class ChatEditorOverlayWidget implements IOverlayWidget {
3132

@@ -97,7 +98,7 @@ class ChatEditorOverlayWidget implements IOverlayWidget {
9798
};
9899
}
99100

100-
if (action.id === 'chatEditor.action.accept' || action.id === 'chatEditor.action.reject') {
101+
if (action.id === AcceptAction.ID || action.id === RejectAction.ID) {
101102
return new class extends ActionViewItem {
102103

103104
private readonly _reveal = this._store.add(new MutableDisposable());

0 commit comments

Comments
 (0)