-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update NotebookModel with changes from VS Code Notebook UI #12048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
76cd7e1
to
6be2eb1
Compare
@@ -363,6 +363,11 @@ export interface INotebookModelModifyChange extends INotebookModelChange { | |||
newCells: ICell[]; | |||
oldCells: ICell[]; | |||
} | |||
export interface INotebookModelCellExecutionCountChange extends INotebookModelChange { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New event.
Using our model as the source of truth. Hence when we update cell execution count, I need an event so I can update VSC code cell.
* | ||
* Hence, we only need to handle auto save when executing cell.s | ||
*/ | ||
// @injectable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Dumped with solution so i don't forget this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will create separate github issue to track this.
traceError(`Unable to find matching cell for ${source}`); | ||
return cells[0]; | ||
} | ||
assert.ok(found.length, `NotebookCell not found, for CellId = ${source.id} in ${source}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fall back just in case VS Code changes their API.
Their API will certainly change, hence this is a good way to track it - i.e. our extension should go kaboom.
FYI - Fairly certain this API will change some time soon microsoft/vscode#98828
* If a VS Code cell changes, then ensure we update the corresponding cell in our INotebookModel. | ||
* I.e. if a cell is added/deleted/moved then update our model. | ||
*/ | ||
export function updateCellModelWithChangesToVSCCell( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file ensures we update changes to VSCode cell when our notebook cell changes, e.g. when we execute cells, then our Notebook model changes and we fire events (existing code), we handle those events here and update the VS Code cells.
Similarly, when user adds/deletes cells then we handle those VSCode cells here and update our model.
I.e. this file is where we keep both models in sync.
} | ||
assert.equal(cell.language, PYTHON_LANGUAGE, 'Cannot create a non Python cell'); | ||
return { | ||
// TODO: Translate output into nbformat.IOutput. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add githuhub issue for this.
}); | ||
|
||
// tslint:disable-next-line: no-any | ||
change.cell.outputs = cellOutputsToVSCCellOutputs(newCellData.outputs as any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is done because this is what causes VS code to update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Kudos, SonarCloud Quality Gate passed!
|
For #10496
Todo:
Will be filing issues (work items) for the pending tasks