You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update the method for determining kernel language (#354)
* Update the method for determining kernel language
The previous algorithm for `getNotebookType()` was based on getting the
kernel spec out of the current notebook. This is a problem when format
is triggered by, for example, `jupyterlab-autosave-on-focus-change`,
immediately after notebook creation. In that case, the language is
determined to be `null` and errors arise.
Now the `onSave()` handler waits for the `sessionContext` to be ready,
then `getNotebookType()` gets the same kernel spec info from the session
rather than the loaded notebook.
* Make metadata access safer at runtime
The `!` operator is a type assertion that the attribute is not null, but
does nothing at runtime to ensure this is the case. I haven't yet found
reproduction steps for this failure, but I encountered a case where
accessing `model!.sharedModel` threw an error. This commit adds optional
chaining operators, which do provide protection at runtime.
* Fall back to session check if metadata is missing
`getNotebookType()` has two ways to determine the language. If the
metadata check fails, it falls through to the current session check.
Previously, if metadata was `null`, the method would return early.
0 commit comments