From 093e21909c4734dfa3e315b56528f14d565ee8f1 Mon Sep 17 00:00:00 2001 From: Ian Huff Date: Mon, 7 Oct 2019 14:27:52 -0700 Subject: [PATCH 1/5] run all native command wired --- package.json | 13 ++++++++++++- src/client/common/application/commands.ts | 1 + src/client/datascience/constants.ts | 1 + .../interactive-common/interactiveWindowTypes.ts | 3 ++- .../datascience/interactive-ipynb/nativeEditor.ts | 4 ++++ .../nativeEditorCommandListener.ts | 8 ++++++++ src/client/datascience/types.ts | 1 + .../native-editor/nativeEditorStateController.ts | 4 ++++ 8 files changed, 33 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c733cd7460c4..712f135e67b5 100644 --- a/package.json +++ b/package.json @@ -524,6 +524,11 @@ "title": "%python.command.python.datascience.restartkernel.title%", "category": "Python" }, + { + "command": "python.datascience.notebookeditor.runallcells", + "title": "%python.command.python.datascience.runallcells.title%", + "category": "Python" + }, { "command": "python.datascience.expandallcells", "title": "%python.command.python.datascience.expandallcells.title%", @@ -778,7 +783,7 @@ "command": "python.datascience.runallcells", "title": "%python.command.python.datascience.runallcells.title%", "category": "Python", - "when": "python.datascience.featureenabled" + "when": "python.datascience.hascodecells && python.datascience.featureenabled" }, { "command": "python.datascience.runFileInteractive", @@ -874,6 +879,12 @@ "category": "Python", "when": "python.datascience.havenative && python.datascience.featureenabled" }, + { + "command": "python.datascience.notebookeditor.runallcells", + "title": "%python.command.python.datascience.runallcells.title%", + "category": "Python", + "when": "python.datascience.havenative && python.datascience.featureenabled" + }, { "command": "python.datascience.expandallcells", "title": "%python.command.python.datascience.expandallcells.title%", diff --git a/src/client/common/application/commands.ts b/src/client/common/application/commands.ts index a059e5b4f6fc..f7b5f3403e24 100644 --- a/src/client/common/application/commands.ts +++ b/src/client/common/application/commands.ts @@ -59,6 +59,7 @@ interface ICommandNameWithoutArgumentTypeMapping { [DSCommands.NotebookEditorRemoveAllCells]: []; [DSCommands.NotebookEditorInterruptKernel]: []; [DSCommands.NotebookEditorRestartKernel]: []; + [DSCommands.NotebookEditorRunAllCells]: []; [DSCommands.ExpandAllCells]: []; [DSCommands.CollapseAllCells]: []; [DSCommands.ExportOutputAsNotebook]: []; diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 3e8c5f24ce40..161416560209 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -35,6 +35,7 @@ export namespace Commands { export const NotebookEditorRemoveAllCells = 'python.datascience.notebookeditor.removeallcells'; export const NotebookEditorInterruptKernel = 'python.datascience.notebookeditor.interruptkernel'; export const NotebookEditorRestartKernel = 'python.datascience.notebookeditor.restartkernel'; + export const NotebookEditorRunAllCells = 'python.datascience.notebookeditor.runallcells'; export const ExpandAllCells = 'python.datascience.expandallcells'; export const CollapseAllCells = 'python.datascience.collapseallcells'; export const ExportOutputAsNotebook = 'python.datascience.exportoutputasnotebook'; diff --git a/src/client/datascience/interactive-common/interactiveWindowTypes.ts b/src/client/datascience/interactive-common/interactiveWindowTypes.ts index 446563bcb4de..c036fbea9f3a 100644 --- a/src/client/datascience/interactive-common/interactiveWindowTypes.ts +++ b/src/client/datascience/interactive-common/interactiveWindowTypes.ts @@ -70,7 +70,7 @@ export namespace InteractiveWindowMessages { export const SaveAll = 'save_all'; export const NativeCommand = 'native_command'; export const VariablesComplete = 'variables_complete'; - + export const RunAllCells = 'run_all_cells'; } export enum NativeCommandType { @@ -303,4 +303,5 @@ export class IInteractiveWindowMapping { public [InteractiveWindowMessages.SaveAll]: ISaveAll; public [InteractiveWindowMessages.NativeCommand]: INativeCommand; public [InteractiveWindowMessages.VariablesComplete]: never | undefined; + public [InteractiveWindowMessages.RunAllCells]: never | undefined; } diff --git a/src/client/datascience/interactive-ipynb/nativeEditor.ts b/src/client/datascience/interactive-ipynb/nativeEditor.ts index ee49ccfbc2c4..75caae10c6ac 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditor.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditor.ts @@ -225,6 +225,10 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { return this.ipynbProvider.getNotebookOptions(); } + public runAllCells() { + this.postMessage(InteractiveWindowMessages.RunAllCells); + } + protected async reopen(cells: ICell[]): Promise { try { super.reload(); diff --git a/src/client/datascience/interactive-ipynb/nativeEditorCommandListener.ts b/src/client/datascience/interactive-ipynb/nativeEditorCommandListener.ts index 97636f9366e2..0d55dad76e78 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditorCommandListener.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditorCommandListener.ts @@ -32,6 +32,14 @@ export class NativeEditorCommandListener implements IDataScienceCommandListener this.disposableRegistry.push(commandManager.registerCommand(Commands.NotebookEditorInterruptKernel, () => this.interruptKernel())); this.disposableRegistry.push(commandManager.registerCommand(Commands.NotebookEditorRestartKernel, () => this.restartKernel())); this.disposableRegistry.push(commandManager.registerCommand(Commands.OpenNotebook, (file?: Uri, _cmdSource: CommandSource = CommandSource.commandPalette) => this.openNotebook(file))); + this.disposableRegistry.push(commandManager.registerCommand(Commands.NotebookEditorRunAllCells, () => this.runAllCells())); + } + + private runAllCells() { + const activeEditor = this.provider.activeEditor; + if (activeEditor) { + activeEditor.runAllCells(); + } } private undoCells() { diff --git a/src/client/datascience/types.ts b/src/client/datascience/types.ts index 637df00766f9..52a1baccff88 100644 --- a/src/client/datascience/types.ts +++ b/src/client/datascience/types.ts @@ -254,6 +254,7 @@ export interface INotebookEditor extends IInteractiveBase { readonly visible: boolean; readonly active: boolean; load(contents: string, file: Uri): Promise; + runAllCells(): void; } export const IInteractiveWindowListener = Symbol('IInteractiveWindowListener'); diff --git a/src/datascience-ui/native-editor/nativeEditorStateController.ts b/src/datascience-ui/native-editor/nativeEditorStateController.ts index 94c685b9d182..f32cced8d381 100644 --- a/src/datascience-ui/native-editor/nativeEditorStateController.ts +++ b/src/datascience-ui/native-editor/nativeEditorStateController.ts @@ -43,6 +43,10 @@ export class NativeEditorStateController extends MainStateController { this.waitingForLoadRender = true; break; + case InteractiveWindowMessages.RunAllCells: + this.runAll(); + break; + default: break; } From c62251dd552f0f83254d51450cb2117a79f3ccbb Mon Sep 17 00:00:00 2001 From: Ian Huff Date: Mon, 7 Oct 2019 16:32:51 -0700 Subject: [PATCH 2/5] add the rest of the commands --- package.json | 50 +++++++++++++++++-- package.nls.json | 4 ++ src/client/common/application/commands.ts | 2 + src/client/datascience/constants.ts | 2 + .../interactiveWindowTypes.ts | 8 ++- .../interactive-ipynb/nativeEditor.ts | 10 +++- .../nativeEditorCommandListener.ts | 16 ++++++ src/client/datascience/types.ts | 2 + .../nativeEditorStateController.ts | 24 ++++++++- 9 files changed, 109 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 712f135e67b5..ddc510a30b82 100644 --- a/package.json +++ b/package.json @@ -511,7 +511,7 @@ }, { "command": "python.datascience.notebookeditor.removeallcells", - "title": "%python.command.python.datascience.removeallcells.title%", + "title": "%python.command.python.datascience.notebookeditor.removeallcells.title%", "category": "Python" }, { @@ -526,7 +526,17 @@ }, { "command": "python.datascience.notebookeditor.runallcells", - "title": "%python.command.python.datascience.runallcells.title%", + "title": "%python.command.python.datascience.notebookeditor.runallcells.title%", + "category": "Python" + }, + { + "command": "python.datascience.notebookeditor.runselectedcell", + "title": "%python.command.python.datascience.notebookeditor.runselectedcell.title%", + "category": "Python" + }, + { + "command": "python.datascience.notebookeditor.addcellbelow", + "title": "%python.command.python.datascience.notebookeditor.addcellbelow.title%", "category": "Python" }, { @@ -785,6 +795,24 @@ "category": "Python", "when": "python.datascience.hascodecells && python.datascience.featureenabled" }, + { + "command": "python.datascience.scrolltocell", + "title": "%python.command.python.datascience.scrolltocell.title%", + "category": "Python", + "when": "false" + }, + { + "command": "python.datascience.debugcell", + "title": "%python.command.python.datascience.debugcell.title%", + "category": "Python", + "when": "python.datascience.hascodecells && python.datascience.featureenabled" + }, + { + "command": "python.datascience.runcell", + "title": "%python.command.python.datascience.runcell.title%", + "category": "Python", + "when": "python.datascience.hascodecells && python.datascience.featureenabled" + }, { "command": "python.datascience.runFileInteractive", "title": "%python.command.python.datascience.runFileInteractive.title%", @@ -863,7 +891,7 @@ }, { "command": "python.datascience.notebookeditor.removeallcells", - "title": "%python.command.python.datascience.removeallcells.title%", + "title": "%python.command.python.datascience.notebookeditor.removeallcells.title%", "category": "Python", "when": "python.datascience.havenativecells && python.datascience.featureenabled" }, @@ -881,7 +909,19 @@ }, { "command": "python.datascience.notebookeditor.runallcells", - "title": "%python.command.python.datascience.runallcells.title%", + "title": "%python.command.python.datascience.notebookeditor.runallcells.title%", + "category": "Python", + "when": "python.datascience.havenative && python.datascience.featureenabled" + }, + { + "command": "python.datascience.notebookeditor.runselectedcell", + "title": "%python.command.python.datascience.notebookeditor.runselectedcell.title%", + "category": "Python", + "when": "python.datascience.havenative && python.datascience.featureenabled" + }, + { + "command": "python.datascience.notebookeditor.addcellbelow", + "title": "%python.command.python.datascience.notebookeditor.addcellbelow.title%", "category": "Python", "when": "python.datascience.havenative && python.datascience.featureenabled" }, @@ -917,7 +957,7 @@ "command": "python.datascience.addcellbelow", "title": "%python.command.python.datascience.addcellbelow.title%", "category": "Python", - "when": "python.datascience.featureenabled" + "when": "python.datascience.hascodecells && python.datascience.featureenabled" }, { "command": "python.datascience.createnewnotebook", diff --git a/package.nls.json b/package.nls.json index fad25ac6bdd7..a8de0a81ab6c 100644 --- a/package.nls.json +++ b/package.nls.json @@ -33,6 +33,7 @@ "python.command.python.datascience.runFileInteractive.title": "Run Current File in Python Interactive Window", "python.command.python.datascience.debugFileInteractive.title": "Debug Current File in Python Interactive Window", "python.command.python.datascience.runallcells.title": "Run All Cells", + "python.command.python.datascience.notebookeditor.runallcells.title": "Run All Notebook Cells", "python.command.python.datascience.runallcellsabove.title": "Run Above", "python.command.python.datascience.runcellandallbelow.title": "Run Below", "python.command.python.datascience.runallcellsabove.palette.title": "Run Cells Above Current Cell", @@ -60,6 +61,9 @@ "python.command.python.datascience.undocells.title": "Undo Last Python Interactive Action", "python.command.python.datascience.redocells.title": "Redo Last Python Interactive Action", "python.command.python.datascience.removeallcells.title": "Delete All Python Interactive Cells", + "python.command.python.datascience.notebookeditor.removeallcells.title": "Delete All Notebook Editor Cells", + "python.command.python.datascience.notebookeditor.runselectedcell.title": "Run Selected Notebook Cell", + "python.command.python.datascience.notebookeditor.addcellbelow.title": "Add Empty Cell to Notebook File", "python.command.python.datascience.interruptkernel.title": "Interrupt IPython Kernel", "python.command.python.datascience.restartkernel.title": "Restart IPython Kernel", "python.command.python.datascience.expandallcells.title": "Expand All Python Interactive Cells", diff --git a/src/client/common/application/commands.ts b/src/client/common/application/commands.ts index f7b5f3403e24..bc1c061cd8e6 100644 --- a/src/client/common/application/commands.ts +++ b/src/client/common/application/commands.ts @@ -60,6 +60,8 @@ interface ICommandNameWithoutArgumentTypeMapping { [DSCommands.NotebookEditorInterruptKernel]: []; [DSCommands.NotebookEditorRestartKernel]: []; [DSCommands.NotebookEditorRunAllCells]: []; + [DSCommands.NotebookEditorRunSelectedCell]: []; + [DSCommands.NotebookEditorAddCellBelow]: []; [DSCommands.ExpandAllCells]: []; [DSCommands.CollapseAllCells]: []; [DSCommands.ExportOutputAsNotebook]: []; diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 161416560209..b962e9e6576c 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -36,6 +36,8 @@ export namespace Commands { export const NotebookEditorInterruptKernel = 'python.datascience.notebookeditor.interruptkernel'; export const NotebookEditorRestartKernel = 'python.datascience.notebookeditor.restartkernel'; export const NotebookEditorRunAllCells = 'python.datascience.notebookeditor.runallcells'; + export const NotebookEditorRunSelectedCell = 'python.datascience.notebookeditor.runselectedcell'; + export const NotebookEditorAddCellBelow = 'python.datascience.notebookeditor.addcellbelow'; export const ExpandAllCells = 'python.datascience.expandallcells'; export const CollapseAllCells = 'python.datascience.collapseallcells'; export const ExportOutputAsNotebook = 'python.datascience.exportoutputasnotebook'; diff --git a/src/client/datascience/interactive-common/interactiveWindowTypes.ts b/src/client/datascience/interactive-common/interactiveWindowTypes.ts index c036fbea9f3a..9025a742f3f0 100644 --- a/src/client/datascience/interactive-common/interactiveWindowTypes.ts +++ b/src/client/datascience/interactive-common/interactiveWindowTypes.ts @@ -70,7 +70,9 @@ export namespace InteractiveWindowMessages { export const SaveAll = 'save_all'; export const NativeCommand = 'native_command'; export const VariablesComplete = 'variables_complete'; - export const RunAllCells = 'run_all_cells'; + export const NotebookRunAllCells = 'notebook_run_all_cells'; + export const NotebookRunSelectedCell = 'notebook_run_selected_cell'; + export const NotebookAddCellBelow = 'notebook_add_cell_below'; } export enum NativeCommandType { @@ -303,5 +305,7 @@ export class IInteractiveWindowMapping { public [InteractiveWindowMessages.SaveAll]: ISaveAll; public [InteractiveWindowMessages.NativeCommand]: INativeCommand; public [InteractiveWindowMessages.VariablesComplete]: never | undefined; - public [InteractiveWindowMessages.RunAllCells]: never | undefined; + public [InteractiveWindowMessages.NotebookRunAllCells]: never | undefined; + public [InteractiveWindowMessages.NotebookRunSelectedCell]: never | undefined; + public [InteractiveWindowMessages.NotebookAddCellBelow]: never | undefined; } diff --git a/src/client/datascience/interactive-ipynb/nativeEditor.ts b/src/client/datascience/interactive-ipynb/nativeEditor.ts index 75caae10c6ac..641734085f67 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditor.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditor.ts @@ -226,7 +226,15 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { } public runAllCells() { - this.postMessage(InteractiveWindowMessages.RunAllCells); + this.postMessage(InteractiveWindowMessages.NotebookRunAllCells); + } + + public runSelectedCell() { + this.postMessage(InteractiveWindowMessages.NotebookRunSelectedCell); + } + + public addCellBelow() { + this.postMessage(InteractiveWindowMessages.NotebookAddCellBelow); } protected async reopen(cells: ICell[]): Promise { diff --git a/src/client/datascience/interactive-ipynb/nativeEditorCommandListener.ts b/src/client/datascience/interactive-ipynb/nativeEditorCommandListener.ts index 0d55dad76e78..158c27674167 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditorCommandListener.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditorCommandListener.ts @@ -33,6 +33,8 @@ export class NativeEditorCommandListener implements IDataScienceCommandListener this.disposableRegistry.push(commandManager.registerCommand(Commands.NotebookEditorRestartKernel, () => this.restartKernel())); this.disposableRegistry.push(commandManager.registerCommand(Commands.OpenNotebook, (file?: Uri, _cmdSource: CommandSource = CommandSource.commandPalette) => this.openNotebook(file))); this.disposableRegistry.push(commandManager.registerCommand(Commands.NotebookEditorRunAllCells, () => this.runAllCells())); + this.disposableRegistry.push(commandManager.registerCommand(Commands.NotebookEditorRunSelectedCell, () => this.runSelectedCell())); + this.disposableRegistry.push(commandManager.registerCommand(Commands.NotebookEditorAddCellBelow, () => this.addCellBelow())); } private runAllCells() { @@ -42,6 +44,20 @@ export class NativeEditorCommandListener implements IDataScienceCommandListener } } + private runSelectedCell() { + const activeEditor = this.provider.activeEditor; + if (activeEditor) { + activeEditor.runSelectedCell(); + } + } + + private addCellBelow() { + const activeEditor = this.provider.activeEditor; + if (activeEditor) { + activeEditor.addCellBelow(); + } + } + private undoCells() { const activeEditor = this.provider.activeEditor; if (activeEditor) { diff --git a/src/client/datascience/types.ts b/src/client/datascience/types.ts index 52a1baccff88..ecf5df12f57d 100644 --- a/src/client/datascience/types.ts +++ b/src/client/datascience/types.ts @@ -255,6 +255,8 @@ export interface INotebookEditor extends IInteractiveBase { readonly active: boolean; load(contents: string, file: Uri): Promise; runAllCells(): void; + runSelectedCell(): void; + addCellBelow(): void; } export const IInteractiveWindowListener = Symbol('IInteractiveWindowListener'); diff --git a/src/datascience-ui/native-editor/nativeEditorStateController.ts b/src/datascience-ui/native-editor/nativeEditorStateController.ts index f32cced8d381..a0da6e139569 100644 --- a/src/datascience-ui/native-editor/nativeEditorStateController.ts +++ b/src/datascience-ui/native-editor/nativeEditorStateController.ts @@ -43,10 +43,18 @@ export class NativeEditorStateController extends MainStateController { this.waitingForLoadRender = true; break; - case InteractiveWindowMessages.RunAllCells: + case InteractiveWindowMessages.NotebookRunAllCells: this.runAll(); break; + case InteractiveWindowMessages.NotebookRunSelectedCell: + this.runSelectedCell(); + break; + + case InteractiveWindowMessages.NotebookAddCellBelow: + this.addNewCell(); + break; + default: break; } @@ -80,6 +88,20 @@ export class NativeEditorStateController extends MainStateController { return index > 0 && cells.find((cvm, i) => i >= index && cvm.cell.data.cell_type === 'code'); } + public runSelectedCell = () => { + this.suspendUpdates(); + const selectedCellId = this.getState().selectedCell; + + if (selectedCellId) { + const cells = this.getState().cellVMs; + const selectedCell = cells.find(cvm => cvm.cell.id === selectedCellId); + if (selectedCell) { + this.submitInput(concatMultilineString(selectedCell.cell.data.source), selectedCell); + } + } + this.resumeUpdates(); + } + public runAll = () => { // Run all code cells (markdown don't need to be run) this.suspendUpdates(); From a6076f84babf5c13cff461f9f0fda1cf3857e20d Mon Sep 17 00:00:00 2001 From: Ian Huff Date: Mon, 7 Oct 2019 16:35:55 -0700 Subject: [PATCH 3/5] add news file --- news/1 Enhancements/7800.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/1 Enhancements/7800.md diff --git a/news/1 Enhancements/7800.md b/news/1 Enhancements/7800.md new file mode 100644 index 000000000000..647a10db36eb --- /dev/null +++ b/news/1 Enhancements/7800.md @@ -0,0 +1 @@ +Add command palette commands for native editor (run all cells, run selected cell, add new cell). And remove interactive window commands from contexts where they don't apply. \ No newline at end of file From 5fc9d928732833f1e7119c15824740085a03f295 Mon Sep 17 00:00:00 2001 From: Ian Huff Date: Mon, 7 Oct 2019 17:07:33 -0700 Subject: [PATCH 4/5] review feedback --- package.json | 2 +- src/client/datascience/constants.ts | 1 + src/client/datascience/interactive-ipynb/nativeEditor.ts | 3 +++ src/client/datascience/interactive-window/interactiveWindow.ts | 3 +++ src/client/datascience/types.ts | 1 + src/datascience-ui/interactive-common/mainStateController.ts | 3 ++- .../native-editor/nativeEditorStateController.ts | 2 -- 7 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ddc510a30b82..31f426c9422f 100644 --- a/package.json +++ b/package.json @@ -917,7 +917,7 @@ "command": "python.datascience.notebookeditor.runselectedcell", "title": "%python.command.python.datascience.notebookeditor.runselectedcell.title%", "category": "Python", - "when": "python.datascience.havenative && python.datascience.featureenabled" + "when": "python.datascience.havenative && python.datascience.featureenabled && python.datascience.havecellselected" }, { "command": "python.datascience.notebookeditor.addcellbelow", diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index b962e9e6576c..388168ab871c 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -74,6 +74,7 @@ export namespace EditorContexts { export const HaveNativeCells = 'python.datascience.havenativecells'; export const HaveNativeRedoableCells = 'python.datascience.havenativeredoablecells'; export const HaveNative = 'python.datascience.havenative'; + export const HaveCellSelected = 'python.datascience.havecellselected'; } export namespace RegExpValues { diff --git a/src/client/datascience/interactive-ipynb/nativeEditor.ts b/src/client/datascience/interactive-ipynb/nativeEditor.ts index 641734085f67..8ee45ab76ffe 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditor.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditor.ts @@ -329,10 +329,13 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { interactiveContext.set(!this.isDisposed).catch(); const interactiveCellsContext = new ContextKey(EditorContexts.HaveNativeCells, this.commandManager); const redoableContext = new ContextKey(EditorContexts.HaveNativeRedoableCells, this.commandManager); + const hasCellSelectedContext = new ContextKey(EditorContexts.HaveCellSelected, this.commandManager); if (info) { interactiveCellsContext.set(info.cellCount > 0).catch(); redoableContext.set(info.redoCount > 0).catch(); + hasCellSelectedContext.set(info.selectedCell ? true : false).catch(); } else { + hasCellSelectedContext.set(false).catch(); interactiveCellsContext.set(false).catch(); redoableContext.set(false).catch(); } diff --git a/src/client/datascience/interactive-window/interactiveWindow.ts b/src/client/datascience/interactive-window/interactiveWindow.ts index 2be69ec9d633..b76b2a06cbb1 100644 --- a/src/client/datascience/interactive-window/interactiveWindow.ts +++ b/src/client/datascience/interactive-window/interactiveWindow.ts @@ -235,12 +235,15 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi interactiveContext.set(!this.isDisposed).catch(); const interactiveCellsContext = new ContextKey(EditorContexts.HaveInteractiveCells, this.commandManager); const redoableContext = new ContextKey(EditorContexts.HaveRedoableCells, this.commandManager); + const hasCellSelectedContext = new ContextKey(EditorContexts.HaveCellSelected, this.commandManager); if (info) { interactiveCellsContext.set(info.cellCount > 0).catch(); redoableContext.set(info.redoCount > 0).catch(); + hasCellSelectedContext.set(info.selectedCell ? true : false).catch(); } else { interactiveCellsContext.set(false).catch(); redoableContext.set(false).catch(); + hasCellSelectedContext.set(false).catch(); } } } diff --git a/src/client/datascience/types.ts b/src/client/datascience/types.ts index ecf5df12f57d..f0edda8be83b 100644 --- a/src/client/datascience/types.ts +++ b/src/client/datascience/types.ts @@ -350,6 +350,7 @@ export interface IInteractiveWindowInfo { undoCount: number; redoCount: number; visibleCells: ICell[]; + selectedCell: string | undefined; } export interface IMessageCell extends nbformat.IBaseCell { diff --git a/src/datascience-ui/interactive-common/mainStateController.ts b/src/datascience-ui/interactive-common/mainStateController.ts index a0b7cab178f7..bfec732c5d23 100644 --- a/src/datascience-ui/interactive-common/mainStateController.ts +++ b/src/datascience-ui/interactive-common/mainStateController.ts @@ -1002,7 +1002,8 @@ export class MainStateController implements IMessageHandler { visibleCells: this.getNonEditCellVMs().map(cvm => cvm.cell), cellCount: this.getNonEditCellVMs().length, undoCount: this.state.undoStack.length, - redoCount: this.state.redoStack.length + redoCount: this.state.redoStack.length, + selectedCell: this.state.selectedCell }; this.sendMessage(InteractiveWindowMessages.SendInfo, info); } diff --git a/src/datascience-ui/native-editor/nativeEditorStateController.ts b/src/datascience-ui/native-editor/nativeEditorStateController.ts index a0da6e139569..2a8310d298a7 100644 --- a/src/datascience-ui/native-editor/nativeEditorStateController.ts +++ b/src/datascience-ui/native-editor/nativeEditorStateController.ts @@ -89,7 +89,6 @@ export class NativeEditorStateController extends MainStateController { } public runSelectedCell = () => { - this.suspendUpdates(); const selectedCellId = this.getState().selectedCell; if (selectedCellId) { @@ -99,7 +98,6 @@ export class NativeEditorStateController extends MainStateController { this.submitInput(concatMultilineString(selectedCell.cell.data.source), selectedCell); } } - this.resumeUpdates(); } public runAll = () => { From a8f75016f9ae16c520853be84a535aefba28d17f Mon Sep 17 00:00:00 2001 From: Ian Huff Date: Tue, 8 Oct 2019 09:03:18 -0700 Subject: [PATCH 5/5] lint errors --- src/client/datascience/interactive-ipynb/nativeEditor.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/datascience/interactive-ipynb/nativeEditor.ts b/src/client/datascience/interactive-ipynb/nativeEditor.ts index 8ee45ab76ffe..9cc529966dfe 100644 --- a/src/client/datascience/interactive-ipynb/nativeEditor.ts +++ b/src/client/datascience/interactive-ipynb/nativeEditor.ts @@ -226,15 +226,15 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { } public runAllCells() { - this.postMessage(InteractiveWindowMessages.NotebookRunAllCells); + this.postMessage(InteractiveWindowMessages.NotebookRunAllCells).ignoreErrors(); } public runSelectedCell() { - this.postMessage(InteractiveWindowMessages.NotebookRunSelectedCell); + this.postMessage(InteractiveWindowMessages.NotebookRunSelectedCell).ignoreErrors(); } public addCellBelow() { - this.postMessage(InteractiveWindowMessages.NotebookAddCellBelow); + this.postMessage(InteractiveWindowMessages.NotebookAddCellBelow).ignoreErrors(); } protected async reopen(cells: ICell[]): Promise {