From 96e087b1540c77fd9ca9427167384f2ec1789db3 Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Thu, 19 Aug 2021 18:57:04 +0000 Subject: [PATCH] Ensure user can undo interactive.input.clear --- .../contrib/interactive/browser/interactive.contribution.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts b/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts index 1482614113e..232b2368df3 100644 --- a/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts +++ b/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts @@ -50,6 +50,7 @@ import { PANEL_BORDER } from 'vs/workbench/common/theme'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { peekViewBorder /*, peekViewEditorBackground, peekViewResultsBackground */ } from 'vs/editor/contrib/peekView/peekView'; import * as icons from 'vs/workbench/contrib/notebook/browser/notebookIcons'; +import { EditOperation } from 'vs/editor/common/core/editOperation'; Registry.as(EditorExtensions.EditorPane).registerEditorPane( @@ -452,9 +453,10 @@ registerAction2(class extends Action2 { if (editorControl && editorControl.notebookEditor && editorControl.codeEditor) { const notebookDocument = editorControl.notebookEditor.textModel; const textModel = editorControl.codeEditor.getModel(); + const range = editorControl.codeEditor.getModel()?.getFullModelRange(); - if (notebookDocument && textModel) { - textModel.setValue(''); + if (notebookDocument && textModel && range) { + editorControl.codeEditor.executeEdits('', [EditOperation.replace(range, null)]); } } }