From ee69e2887fbe532588f74ae86560e7fdc1e59550 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Tue, 20 Feb 2024 18:35:32 -0800 Subject: [PATCH] Notebook chat editing enhancements. (#205799) * Notebook chat editing enhancements. * hide cell chat actions from f1. --- .../notebook/browser/controller/chat/cellChatActions.ts | 2 ++ .../browser/controller/chat/notebookChatController.ts | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.ts b/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.ts index 8c97251257ec4..430062261c9fc 100644 --- a/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.ts @@ -382,6 +382,7 @@ registerAction2(class extends NotebookAction { } ] }, + f1: false, menu: [ { id: MenuId.NotebookCellBetween, @@ -454,6 +455,7 @@ registerAction2(class extends NotebookAction { original: '$(sparkle) Generate', }, tooltip: localize('notebookActions.menu.insertCodeCellWithChat.tooltip', "Generate Code Cell with Chat"), + f1: false, menu: [ { id: MenuId.NotebookCellListTop, diff --git a/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.ts b/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.ts index 7686f52b8b307..cec4fe9242f63 100644 --- a/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.ts +++ b/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.ts @@ -369,7 +369,7 @@ export class NotebookChatController extends Disposable implements INotebookEdito const cellTop = this._notebookEditor.getAbsoluteTopOfElement(previousCell); const cellHeight = this._notebookEditor.getHeightOfElement(previousCell); - this._notebookEditor.revealOffsetInCenterIfOutsideViewport(cellTop + cellHeight); + this._notebookEditor.revealOffsetInCenterIfOutsideViewport(cellTop + cellHeight + 48 /** center of the dialog */); } } } @@ -412,6 +412,12 @@ export class NotebookChatController extends Disposable implements INotebookEdito return; } + if (this._widget.editingCell && this._widget.editingCell.textBuffer.getLength() > 0) { + // it already contains some text, clear it + const ref = await this._widget.editingCell.resolveTextModel(); + ref.setValue(''); + } + const editingCellIndex = this._widget.editingCell ? this._notebookEditor.getCellIndex(this._widget.editingCell) : undefined; if (editingCellIndex !== undefined) { this._notebookEditor.setSelections([{