From 4661aa6e09b1f8c80fd0f7ce07d675770b143802 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 26 May 2023 12:55:05 +0200 Subject: [PATCH] inline chat tweaks (#183520) * move toggle diff btn into drop down menu * fix a few issues when restoring an IE session --- .../browser/interactiveEditorActions.ts | 11 +++++++---- .../browser/interactiveEditorController.ts | 2 ++ .../browser/interactiveEditorWidget.ts | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorActions.ts b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorActions.ts index 6edc0f396a9b8..c997ada83b06e 100644 --- a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorActions.ts +++ b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorActions.ts @@ -306,6 +306,7 @@ export class DiscardAction extends AbstractInteractiveEditorAction { }, menu: { id: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD, + group: '0_main', order: 0 } }); @@ -330,6 +331,7 @@ export class DiscardToClipboardAction extends AbstractInteractiveEditorAction { // }, menu: { id: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD, + group: '0_main', order: 1 } }); @@ -353,6 +355,7 @@ export class DiscardUndoToNewFileAction extends AbstractInteractiveEditorAction precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_DID_EDIT), menu: { id: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD, + group: '0_main', order: 2 } }); @@ -420,12 +423,12 @@ export class ToggleInlineDiff extends AbstractInteractiveEditorAction { title: localize('toggleDiff', 'Toggle Diff'), icon: Codicon.diff, precondition: ContextKeyExpr.and(CTX_INTERACTIVE_EDITOR_VISIBLE, CTX_INTERACTIVE_EDITOR_DID_EDIT), - toggled: CTX_INTERACTIVE_EDITOR_SHOWING_DIFF, + toggled: { condition: CTX_INTERACTIVE_EDITOR_SHOWING_DIFF, title: localize('toggleDiff2', "Show Inline Diff") }, menu: { - id: MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, + id: MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD, when: CTX_INTERACTIVE_EDITOR_EDIT_MODE.notEqualsTo(EditMode.Preview), - group: '0_main', - order: 10 + group: '1_config', + order: 9 } }); } diff --git a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts index c86005283ea9f..66e91bf8b796e 100644 --- a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts +++ b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts @@ -257,6 +257,7 @@ export class InteractiveEditorController implements IEditorContribution { this._zone.widget.updateSlashCommands(this._activeSession.session.slashCommands ?? []); this._zone.widget.placeholder = this._getPlaceholderText(); + this._zone.widget.value = this._activeSession.lastInput ?? ''; this._zone.widget.updateInfo(this._activeSession.session.message ?? localize('welcome.1', "AI-generated code may be incorrect")); this._zone.show(this._activeSession.wholeRange.getEndPosition()); @@ -558,6 +559,7 @@ export class InteractiveEditorController implements IEditorContribution { try { this._ignoreModelContentChanged = true; await this._strategy.renderChanges(response); + this._ctxDidEdit.set(this._activeSession.hasChangedText); } finally { this._ignoreModelContentChanged = false; } diff --git a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget.ts b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget.ts index 1a0e3bee17b8b..dedc3cb72deae 100644 --- a/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget.ts +++ b/src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget.ts @@ -424,6 +424,7 @@ export class InteractiveEditorWidget { this._elements.statusToolbar.classList.toggle('hidden', !show); this._elements.feedbackToolbar.classList.toggle('hidden', !show); this._elements.status.classList.toggle('actions', show); + this._elements.infoLabel.classList.toggle('hidden', show); this._onDidChangeHeight.fire(); }