Skip to content

Commit

Permalink
Update getInteractiveCellMetadata callsites
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl committed Sep 1, 2021
1 parent 699447c commit 9a08f5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/client/datascience/editor-integration/cellhashprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ export class CellHashProvider implements ICellHashProvider {
// Find the text document that matches. We need more information than
// the add code gives us
const { line: cellLine, file } = cell.metadata.interactive;
const id = getInteractiveCellMetadata(cell).id;
const id = getInteractiveCellMetadata(cell)?.id;
const doc = this.documentManager.textDocuments.find((d) => this.fs.areLocalPathsSame(d.fileName, file));
if (doc) {
if (doc && id) {
// Compute the code that will really be sent to jupyter
const { stripped, trueStartLine } = this.extractStrippedLines(cell);

Expand Down
5 changes: 4 additions & 1 deletion src/client/datascience/editor-integration/hoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export class HoverProvider implements INotebookExecutionLogger, IHoverProvider {
return;
}
const size = this.runFiles.size;
this.runFiles.add(getInteractiveCellMetadata(e.cell).interactive.file.toLocaleLowerCase());
const metadata = getInteractiveCellMetadata(e.cell);
if (metadata !== undefined) {
this.runFiles.add(metadata.interactive.file.toLocaleLowerCase());
}
if (size !== this.runFiles.size) {
await this.initializeHoverProvider();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export class InteractiveWindow implements IInteractiveWindowLoadable {
const notebookEditor = await this._editorReadyPromise;
const matchingCell = notebookEditor.document
.getCells()
.find((cell) => getInteractiveCellMetadata(cell).id === id);
.find((cell) => getInteractiveCellMetadata(cell)?.id === id);
if (matchingCell) {
this.revealCell(matchingCell, notebookEditor);
}
Expand All @@ -516,13 +516,12 @@ export class InteractiveWindow implements IInteractiveWindowLoadable {
}, 200); // Rendering output is async so the output is not guaranteed to immediately exist
}

// TODO this does not need to be async since we no longer need to roundtrip to the UI
public async hasCell(id: string): Promise<boolean> {
const notebookEditor = await this._editorReadyPromise;
if (!notebookEditor) {
return false;
}
return notebookEditor.document.getCells().some((cell) => getInteractiveCellMetadata(cell).id === id);
return notebookEditor.document.getCells().some((cell) => getInteractiveCellMetadata(cell)?.id === id);
}

public get owningResource(): Resource {
Expand Down

0 comments on commit 9a08f5c

Please sign in to comment.