Skip to content

Notebook: Undo/Redo #92811

@rebornix

Description

@rebornix

Issue Type: Feature Request

Notebook is a resource which contains multiple text models so it leads to interesting requirements for workspace Undo/Redo. Right now there are three major scenarios

  • Users are editing the content of a cell (focus is now in a monaco editor), Undo/Redo should work inside this editor. We already have this support.
  • Users add/delete a cell, Undo/Redo should remove/re-add cells. We can archive this by undoRedoService.pushElement(resource) and the resource passed in is the resource uri of the notebook document
  • 🔴 Users do find & replace all on the notebook document. The change is a WorkspaceEdit and Undo/Redo is not working properly
    • We use BulkEditService to apply the WorksapceEdit. WorkspaceEdit consists of edits for multiple cells, which are all TextModels.
    • To Undo/Redo the WorkspaceEdit, we have to focus the text editor for the first modified cell of the WorkspaceEdit. However, we want to allow Undo/Redo when the focus is not in any text editor.

I'm wondering if we can add something like undoRedoAllowedResources property to the IWorkspaceUndoRedoElement, thus in the notebook case, it will always be [notebookUri, firstModifiedCellUri].

export interface IWorkspaceUndoRedoElement {
	readonly type: UndoRedoElementType.Workspace;
	readonly resources: readonly URI[];
+       readonly undoRedoAllowedResources: URI[];
	readonly label: string;
	undo(): Promise<void> | void;
	redo(): Promise<void> | void;
	split(): IResourceUndoRedoElement[];
}

cc @mjbvz

VS Code version: Code - Insiders 1.44.0-insider (798481c, 2020-03-16T07:10:59.884Z)
OS version: Darwin x64 19.2.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions