From 44a2d009c025648809ffef104ec95bda3feebdd5 Mon Sep 17 00:00:00 2001 From: Yurong He Date: Tue, 30 Apr 2019 13:25:11 -0700 Subject: [PATCH] Fixed #4169 shows notification when not active code cell is selected when hit F5 (#5259) * Refine the msg --- .../api/node/mainThreadNotebookDocumentsAndEditors.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/sql/workbench/api/node/mainThreadNotebookDocumentsAndEditors.ts b/src/sql/workbench/api/node/mainThreadNotebookDocumentsAndEditors.ts index 4221d7e13f..23c052e12e 100644 --- a/src/sql/workbench/api/node/mainThreadNotebookDocumentsAndEditors.ts +++ b/src/sql/workbench/api/node/mainThreadNotebookDocumentsAndEditors.ts @@ -31,6 +31,7 @@ import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/un import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor'; import { notebookModeId } from 'sql/workbench/common/customInputConverter'; +import { localize } from 'vs/nls'; class MainThreadNotebookEditor extends Disposable { private _contentChangedEmitter = new Emitter(); @@ -360,12 +361,9 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements } else { // Use the active cell in this case, or 1st cell if there's none active cell = editor.model.activeCell; - if (!cell) { - cell = editor.cells.find(c => c.cellType === CellTypes.Code); - } } - if (!cell) { - return Promise.reject(disposed(`Could not find cell for this Notebook`)); + if (!cell || (cell && cell.cellType !== CellTypes.Code)) { + return Promise.reject(new Error(localize('runActiveCell', "F5 shortcut key requires a code cell to be selected. Please select a code cell to run."))); } return editor.runCell(cell);