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);