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
{{ message }}
Repository navigation
API request - Support interactive window natively #154983
As described in #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:
Eliminate URI parsing in extensions and language servers
Eliminate the usage of a command to create an interactive window
Propose an API for creating interactive windows (based on the 'interactive.open' command used now)
Propose an API for adding new cells into the history
Change the current notebook API to include the special 'input' cell as part of the interactive notebook.
// Under vscode.workspace namespace/** * Creates a new interactive window * @param resource interactive resource uri * @param title title of the editor * @param initialController controller to start with * @param options options for viewing */exportfunctionopenInteractiveWindow(resource?: Uri,title?: string,initialController?: NotebookController,options?: {viewColumn?: ViewColumn;preserveFocus?: boolean}): Thenable<NotebookDocument>;// Under vscode.NotebookEdit class/** * Utility to create an edit that adds to an interactive window * @param newCells the new cells */staticaddInteractiveCells(newCells: NotebookCellData[]): NotebookEdit;
Additionally the notebook API for the interactive window should include the input box in its list of cells.
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;
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
#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:
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.
export interface NotebookDocumentShowOptions {
/**
* The notebook should be opened in a REPL editor,
* where the last cell of the notebook is an input box and the other cells are the read-only history.
* When the value is a string, it will be used as the label for the editor tab.
*/
readonly asRepl?: boolean | string | {
/**
* The label to be used for the editor tab.
*/
readonly label: string;
};
}
export interface NotebookEditor {
/**
* Information about the REPL editor if the notebook was opened as a repl.
*/
replOptions?: {
/**
* The index where new cells should be appended.
*/
appendIndex: number;
};
}
Notes
The asRepl flag only has an effect if the notebook is not already shown
The appendIndex on the editor means you need the editor object to edit the document
Getting an editor instance requires(?) calling openEditor, or holding that object from a previous call
Activity
amunger commentedon Jul 12, 2022
an alternative to
addInteractiveCellscould be to add an override toinsertCellswith 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.jrieken commentedon Jul 19, 2022
Some post-sync findings/thoughts:
NotebookDocumentshould have a flag to signal that it is in interactive moderchiodo commentedon Jul 19, 2022
/cc Peng Lyu (@rebornix)
amunger commentedon Sep 3, 2024
#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:
and the
NotebookEditobject returned has a required range field. Making aNotebookEditobject that represents cells that should be appended to the end would likely break any type checking.amunger commentedon Nov 11, 2024
Current proposed API
Notes
asReplflag only has an effect if the notebook is not already shownappendIndexon the editor means you need the editor object to edit the documentopenEditor, or holding that object from a previous call