Skip to content
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

API request - Support interactive window natively #154983

Open
rchiodo opened this issue Jul 12, 2022 · 4 comments
Open

API request - Support interactive window natively #154983

rchiodo opened this issue Jul 12, 2022 · 4 comments
Assignees
Labels
api-proposal feature-request Request for new features or functionality interactive-window

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Jul 12, 2022

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
		 */
		export function openInteractiveWindow(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
		 */
		static addInteractiveCells(newCells: NotebookCellData[]): NotebookEdit;

Additionally the notebook API for the interactive window should include the input box in its list of cells.

@amunger
Copy link
Contributor

amunger commented Jul 12, 2022

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;

@jrieken
Copy link
Member

jrieken commented Jul 19, 2022

Some post-sync findings/thoughts:

  • interactive window should be fully backed by notebook document, e.g also include the "input cell"
  • the NotebookDocument should have a flag to signal that it is in interactive mode
  • 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
  • add some way to open a new notebook as interactive
  • ? figure out if the NotebookController#updateAffinity is good enough to strong-bind a controller to an interactive document
  • ? should/can all notebook types support interactive mode

@rchiodo
Copy link
Contributor Author

rchiodo commented Jul 19, 2022

/cc @rebornix

@amunger
Copy link
Contributor

amunger commented Sep 3, 2024

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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-proposal feature-request Request for new features or functionality interactive-window
Projects
None yet
Development

No branches or pull requests

4 participants