Open rchiodo opened 2 years ago
an alternative to addInteractiveCells
could be to add an override to insertCells
with no index parameter. VS Code could determine that the notebook represents an Interactive window and insert to the correct place (n-1), otherwise just append to the end.
/**
* Utility to create an edit that appends cells to a notebook or interactive window.
*
* @param newCells The new notebook cells.
*/
static insertCells(newCells: NotebookCellData[]): NotebookEdit;
Some post-sync findings/thoughts:
NotebookDocument
should have a flag to signal that it is in interactive mode/cc @rebornix
with the flag set only some edit operations are allowed, namely only to insert above the "input cell" add some suger-edit-functions to make the former restriction simpler
https://github.com/microsoft/vscode/pull/227258 would enforce the edit restrictions, but adding the more convenient API functions looks pretty tricky since notebook edits are created without any reference to a model:
static insertCells(index: number, newCells: NotebookCellData[]): NotebookEdit;
and the NotebookEdit
object returned has a required range field. Making a NotebookEdit
object that represents cells that should be appended to the end would likely break any type checking.
As described in https://github.com/microsoft/vscode/issues/151994 extensions have to have special knowledge about the interactive window URI in order to handle things like inserting new cells and intellisense.
This issue is to:
Additionally the notebook API for the interactive window should include the input box in its list of cells.