Joh/mysterious-octopus (#202079)

* debt - don't use extra buttons for accept/discard hunk

* - inline chat history shouldn't loop
- preserve the initial value and restore it

fixes https://github.com/microsoft/vscode-copilot-release/issues/671
This commit is contained in:
Johannes Rieken
2024-01-09 15:43:26 +01:00
committed by GitHub
parent 66bf39bd4e
commit 77ca6ccd41
5 changed files with 97 additions and 59 deletions

View File

@@ -303,6 +303,29 @@ export class NextFromHistory extends AbstractInlineChatAction {
}
}
export class DiscardHunkAction extends AbstractInlineChatAction {
constructor() {
super({
id: 'inlineChat.discardHunkChange',
title: localize('discard', 'Discard'),
icon: Codicon.clearAll,
precondition: CTX_INLINE_CHAT_VISIBLE,
menu: {
id: MENU_INLINE_CHAT_WIDGET_STATUS,
when: ContextKeyExpr.and(CTX_INLINE_CHAT_RESPONSE_TYPES.notEqualsTo(InlineChatResponseTypes.OnlyMessages), CTX_INLINE_CHAT_EDIT_MODE.isEqualTo(EditMode.Live)),
group: '0_main',
order: 3
}
});
}
async runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): Promise<void> {
return ctrl.discardHunk();
}
}
MenuRegistry.appendMenuItem(MENU_INLINE_CHAT_WIDGET_STATUS, {
submenu: MENU_INLINE_CHAT_WIDGET_DISCARD,
title: localize('discardMenu', "Discard..."),
@@ -510,7 +533,7 @@ export class AcceptChanges extends AbstractInlineChatAction {
when: CTX_INLINE_CHAT_USER_DID_EDIT
}],
menu: {
when: ContextKeyExpr.and(CTX_INLINE_CHAT_RESPONSE_TYPES.notEqualsTo(InlineChatResponseTypes.OnlyMessages), CTX_INLINE_CHAT_EDIT_MODE.notEqualsTo(EditMode.Live)),
when: ContextKeyExpr.and(CTX_INLINE_CHAT_RESPONSE_TYPES.notEqualsTo(InlineChatResponseTypes.OnlyMessages)),
id: MENU_INLINE_CHAT_WIDGET_STATUS,
group: '0_main',
order: 0
@@ -519,7 +542,7 @@ export class AcceptChanges extends AbstractInlineChatAction {
}
override async runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController): Promise<void> {
ctrl.acceptSession();
ctrl.acceptHunk();
}
}
@@ -549,6 +572,7 @@ export class CancelSessionAction extends AbstractInlineChatAction {
}
}
export class CloseAction extends AbstractInlineChatAction {
constructor() {