Skip to content

Commit 0b70bda

Browse files
authored
Candidate: NB multiselect undo/redo fix (microsoft#235522)
update viewmodel via cursor controller after undo/redo op
1 parent f05250e commit 0b70bda

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,18 @@ export class NotebookMultiCursorController extends Disposable implements INotebo
385385
}
386386
}
387387

388+
private updateViewModelSelections() {
389+
for (const cell of this.trackedCells) {
390+
const controller = this.cursorsControllers.get(cell.cellViewModel.uri);
391+
if (!controller) {
392+
// should not happen
393+
return;
394+
}
395+
396+
cell.cellViewModel.setSelections(controller.getSelections());
397+
}
398+
}
399+
388400
private updateFinalUndoRedo() {
389401
const anchorCellModel = this.anchorCell?.[1].getModel();
390402
if (!anchorCellModel) {
@@ -775,16 +787,10 @@ export class NotebookMultiCursorController extends Disposable implements INotebo
775787
if (model) {
776788
models.push(model);
777789
}
778-
779-
const controller = this.cursorsControllers.get(cell.cellViewModel.uri);
780-
if (!controller) {
781-
// should not happen
782-
return;
783-
}
784-
controller.setSelections(new ViewModelEventsCollector(), undefined, cell.cellViewModel.getSelections(), CursorChangeReason.Explicit);
785790
}
786791

787792
await Promise.all(models.map(model => model.undo()));
793+
this.updateViewModelSelections();
788794
this.updateLazyDecorations();
789795
}
790796

@@ -795,16 +801,10 @@ export class NotebookMultiCursorController extends Disposable implements INotebo
795801
if (model) {
796802
models.push(model);
797803
}
798-
799-
const controller = this.cursorsControllers.get(cell.cellViewModel.uri);
800-
if (!controller) {
801-
// should not happen
802-
return;
803-
}
804-
controller.setSelections(new ViewModelEventsCollector(), undefined, cell.cellViewModel.getSelections(), CursorChangeReason.Explicit);
805804
}
806805

807806
await Promise.all(models.map(model => model.redo()));
807+
this.updateViewModelSelections();
808808
this.updateLazyDecorations();
809809
}
810810

0 commit comments

Comments
 (0)