Skip to content

Commit

Permalink
Honor jupyter.stopOnError when running multiple cells in native int…
Browse files Browse the repository at this point in the history
…eractive window (#6682)

* 🤡

* no floating promises
  • Loading branch information
joyceerhl authored Jul 15, 2021
1 parent cf925bd commit e3a963b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/client/datascience/cellFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export function generateCellsFromNotebookDocument(
): ICell[] {
return notebookDocument
.getCells()
.filter((cell) => !cell.metadata.isSysInfoCell)
.filter((cell) => !cell.metadata.isInteractiveWindowMessageCell)
.map((cell) => {
// Reinstate cell structure + comments from cell metadata
let code = cell.document.getText().splitLines();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,12 @@ export class NativeInteractiveWindow implements IInteractiveWindowLoadable {
// Add message to the notebook document
const edit = new WorkspaceEdit();
const notebookDocument = this.notebookDocument;
const markdownCell = new NotebookCellData(NotebookCellKind.Markup, message, MARKDOWN_LANGUAGE);
markdownCell.metadata = { isInteractiveWindowMessageCell: true };
edit.replaceNotebookCells(
notebookDocument.uri,
new NotebookRange(notebookDocument.cellCount, notebookDocument.cellCount),
[new NotebookCellData(NotebookCellKind.Markup, message, MARKDOWN_LANGUAGE)]
[markdownCell]
);
await workspace.applyEdit(edit);
}
Expand Down Expand Up @@ -390,20 +392,21 @@ export class NativeInteractiveWindow implements IInteractiveWindowLoadable {

// Sign up for cell changes
observable.subscribe(
async (cells: ICell[]) => {
(cells: ICell[]) => {
// Then send the combined output to the UI
const converted = (cells[0].data as nbformat.ICodeCell).outputs.map(cellOutputToVSCCellOutput);
await temporaryExecution.replaceOutput(converted);
// Scroll to the newly added output. First recompute visibility.
// User might have scrolled away while cell was executing.
// We don't want to force them back down unless they configured
// alwaysScrollOnNewCell.
const isInsertedCellVisible = editor?.visibleRanges.find((r) => {
return r.end === this.notebookDocument.cellCount - 1;
void temporaryExecution.replaceOutput(converted).then(() => {
// Scroll to the newly added output. First recompute visibility.
// User might have scrolled away while cell was executing.
// We don't want to force them back down unless they configured
// alwaysScrollOnNewCell.
const isInsertedCellVisible = editor?.visibleRanges.find((r) => {
return r.end === this.notebookDocument.cellCount - 1;
});
if (settings.alwaysScrollOnNewCell || isInsertedCellVisible) {
this.revealCell(notebookCell);
}
});
if (settings.alwaysScrollOnNewCell || isInsertedCellVisible) {
this.revealCell(notebookCell);
}
const executionCount = (cells[0].data as nbformat.ICodeCell).execution_count;
if (executionCount) {
temporaryExecution.executionOrder = parseInt(executionCount.toString(), 10);
Expand All @@ -430,7 +433,9 @@ export class NativeInteractiveWindow implements IInteractiveWindowLoadable {
await finishedAddingCode.promise;
traceInfo(`Finished execution for ${id}`);
} finally {
await this.jupyterDebugger.stopDebugging(notebook);
if (isDebug) {
await this.jupyterDebugger.stopDebugging(notebook);
}
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/jupyter/kernels/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class Kernel implements IKernel {
sysInfoMessages.join(' \n'),
MARKDOWN_LANGUAGE
);
markdownCell.metadata = { isSysInfoCell: true };
markdownCell.metadata = { isInteractiveWindowMessageCell: true };
edit.replaceNotebookCells(
notebookDocument.uri,
new NotebookRange(notebookDocument.cellCount, notebookDocument.cellCount),
Expand Down

0 comments on commit e3a963b

Please sign in to comment.