mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-10 09:03:02 +08:00
Clear undo/redo stack upon receiving a concurrent delta (#12)
This commit is contained in:
parent
3e6a4adce2
commit
b8df31e1ae
1 changed files with 10 additions and 1 deletions
|
@ -34,8 +34,17 @@ export default class MonacoEditorAdapter {
|
|||
applyDelta(delta) {
|
||||
const operations = this.__deltaToEditorOperations(delta);
|
||||
this.ignoreChange = true;
|
||||
this.editor.getModel().pushEditOperations([], operations);
|
||||
// Apply the operations without adding them to the undo stack
|
||||
this.editor.getModel().applyEdits(operations);
|
||||
this.ignoreChange = false;
|
||||
|
||||
// Clear the undo/redo stack as the operations may no longer be valid
|
||||
// after applying the concurrent change.
|
||||
// Note: there's not public method for getting EditStack for the text model,
|
||||
// so we use the private attribute.
|
||||
// (https://github.com/microsoft/vscode/blob/11ac71b27220a2354b6bb28966ed3ead183cc495/src/vs/editor/common/model/textModel.ts#L287)
|
||||
const editStack = this.editor.getModel()._commandManager;
|
||||
editStack.clear();
|
||||
}
|
||||
|
||||
__deltaFromEditorChange(event) {
|
||||
|
|
Loading…
Reference in a new issue