From 039751ded6018177e5d53db5f1fa364fc7f7c2c7 Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Wed, 18 Aug 2021 23:16:21 +0000 Subject: [PATCH] Re: https://github.com/microsoft/vscode-jupyter/issues/7157 --- .../browser/interactive.contribution.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts b/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts index 6d8fa05a984..1482614113e 100644 --- a/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts +++ b/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts @@ -435,6 +435,31 @@ registerAction2(class extends Action2 { } }); +registerAction2(class extends Action2 { + constructor() { + super({ + id: 'interactive.input.clear', + title: { value: localize('interactive.input.clear', "Clear the interactive window input editor contents"), original: 'Clear the interactive window input editor contents' }, + category: 'Interactive', + f1: false + }); + } + + async run(accessor: ServicesAccessor): Promise { + const editorService = accessor.get(IEditorService); + const editorControl = editorService.activeEditorPane?.getControl() as { notebookEditor: NotebookEditorWidget | undefined, codeEditor: CodeEditorWidget; } | undefined; + + if (editorControl && editorControl.notebookEditor && editorControl.codeEditor) { + const notebookDocument = editorControl.notebookEditor.textModel; + const textModel = editorControl.codeEditor.getModel(); + + if (notebookDocument && textModel) { + textModel.setValue(''); + } + } + } +}); + registerAction2(class extends Action2 { constructor() { super({