🐛 fix reading of unopened ipynb files
This commit is contained in:
parent
3f83c6a3e8
commit
6f962b3727
1 changed files with 9 additions and 4 deletions
|
|
@ -300,9 +300,13 @@ export class VsCodeIdeUtils {
|
|||
|
||||
// First, check whether it's a notebook document
|
||||
// Need to iterate over the cells to get full contents
|
||||
const notebook = vscode.workspace.notebookDocuments.find(
|
||||
(doc) => doc.uri.toString() === uri.toString(),
|
||||
);
|
||||
const notebook =
|
||||
vscode.workspace.notebookDocuments.find(
|
||||
(doc) => doc.uri.toString() === uri.toString(),
|
||||
) ??
|
||||
(uri.fsPath.endsWith("ipynb")
|
||||
? await vscode.workspace.openNotebookDocument(uri)
|
||||
: undefined);
|
||||
if (notebook) {
|
||||
return notebook
|
||||
.getCells()
|
||||
|
|
@ -331,7 +335,8 @@ export class VsCodeIdeUtils {
|
|||
const truncatedBytes = bytes.slice(0, VsCodeIdeUtils.MAX_BYTES);
|
||||
const contents = new TextDecoder().decode(truncatedBytes);
|
||||
return contents;
|
||||
} catch {
|
||||
} catch (e) {
|
||||
console.warn("Error reading file", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue