Skip to content

Commit

Permalink
don't assume that there is a progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Mar 20, 2020
1 parent 42be38c commit 37865c4
Showing 1 changed file with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,33 +334,39 @@ async function runActiveCell(accessor: ServicesAccessor): Promise<ICellViewModel
}

async function runCell(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
const progress = context.cellTemplate!.progressBar!;
progress.infinite().show(500);

const editorService = accessor.get(IEditorService);
const notebookService = accessor.get(INotebookService);

const resource = editorService.activeEditor?.resource;
if (!resource) {
return;
const progress = context.cellTemplate?.progressBar;
if (progress) {
progress.infinite().show(500);
}
try {
const editorService = accessor.get(IEditorService);
const notebookService = accessor.get(INotebookService);

const editor = getActiveNotebookEditor(editorService);
if (!editor) {
return;
}
const resource = editorService.activeEditor?.resource;
if (!resource) {
return;
}

const notebookProviders = notebookService.getContributedNotebookProviders(resource);
if (!notebookProviders.length) {
return;
}
const editor = getActiveNotebookEditor(editorService);
if (!editor) {
return;
}

// Need to make active, maybe TODO
editor.focusNotebookCell(context.cell, false);
const notebookProviders = notebookService.getContributedNotebookProviders(resource);
if (!notebookProviders.length) {
return;
}

const viewType = notebookProviders[0].id;
await notebookService.executeNotebookActiveCell(viewType, resource);
progress.hide();
// Need to make active, maybe TODO
editor.focusNotebookCell(context.cell, false);

const viewType = notebookProviders[0].id;
await notebookService.executeNotebookActiveCell(viewType, resource);
} finally {
if (progress) {
progress.hide();
}
}
}

async function changeActiveCellToKind(kind: CellKind, accessor: ServicesAccessor): Promise<void> {
Expand Down

0 comments on commit 37865c4

Please sign in to comment.