Skip to content

Commit

Permalink
Don't format if the notebook type is undetermined
Browse files Browse the repository at this point in the history
In the event that `getNotebookType()` is null, an error is shown from
within `getFormattersToUse()` because it can't determine the list of
default formatters. This makes sense when using an unconfigured
language, but in the event of null, this seems to mean the notebook
isn't fully initialized and formatting shouldn't even be attempted.
  • Loading branch information
shreve committed Aug 5, 2024
1 parent 55a9d04 commit 6023a85
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
}
try {
this.working = true;
if (this.getNotebookType() === null) {
this.working = false;
return;
}
const selectedCells = this.getCodeCells(selectedOnly, notebook);
if (selectedCells.length === 0) {
this.working = false;
Expand Down

0 comments on commit 6023a85

Please sign in to comment.