fix #128173.
This commit is contained in:
parent
c6bb76dc49
commit
14cd42cca4
1 changed files with 10 additions and 3 deletions
|
@ -17,8 +17,15 @@ class NotebookUndoRedoContribution extends Disposable {
|
||||||
constructor(@IEditorService private readonly _editorService: IEditorService) {
|
constructor(@IEditorService private readonly _editorService: IEditorService) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
const PRIORITY = 105;
|
/**
|
||||||
this._register(UndoCommand.addImplementation(PRIORITY, 'notebook-undo-redo', () => {
|
* The undo/redo priority needs to be above code editors due to how the undo redo service works. Say we have two cells, cell 0 and cell 100, which can't be rendered in the same viewport
|
||||||
|
* 1. focus cell 0, type
|
||||||
|
* 2. focus cell 100. Cell 0 becomes invisible, the text model for it is disposed, which will mark the undo element "invalid"
|
||||||
|
* 3. undo. Since the last undo element is invalid, it will remove this undo element directly other than performing any real undo.
|
||||||
|
*
|
||||||
|
* We now make the notebook undo/redo impl the highest priority so we don't skip the "invalid" undo/redo element in the same notebook document
|
||||||
|
*/
|
||||||
|
this._register(UndoCommand.addImplementation(10000 + 5, 'notebook-undo-redo', () => {
|
||||||
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
|
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
|
||||||
if (editor?.viewModel) {
|
if (editor?.viewModel) {
|
||||||
return editor.viewModel.undo().then(cellResources => {
|
return editor.viewModel.undo().then(cellResources => {
|
||||||
|
@ -37,7 +44,7 @@ class NotebookUndoRedoContribution extends Disposable {
|
||||||
return false;
|
return false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._register(RedoCommand.addImplementation(PRIORITY, 'notebook-undo-redo', () => {
|
this._register(RedoCommand.addImplementation(10000 + 5, 'notebook-undo-redo', () => {
|
||||||
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
|
const editor = getNotebookEditorFromEditorPane(this._editorService.activeEditorPane);
|
||||||
if (editor?.viewModel) {
|
if (editor?.viewModel) {
|
||||||
return editor.viewModel.redo().then(cellResources => {
|
return editor.viewModel.redo().then(cellResources => {
|
||||||
|
|
Loading…
Reference in a new issue