Description
Monaco has a concept of "undo stops" but doesn't give a way to access it without actually invoking undo.
I instrumented the onDidChangeContent
with:
const model = editor.getModel();
model.onDidChangeContent(() => {
console.log(model.getAlternativeVersionId());
});
And I can see that if I type "one two" then press undo, I see:
1 // o
2 // n
3 // e
4 // space
5 // t
6 // w
7 // o
3 // undo restores the text to "one"
So Monaco has decided to put an undo-stop in after version 3 based on some internal logic.
My wish: I'd like a field in IModelContentChangedEvent to indicate when an undo stop is created. eg.
model.onDidChangeContent(({isNewUndoStackElement}) => {
// In the above example, isNewUndoStackElement would be true on the 1st and 4th call
});
The reason I want this is so I can integrate this into the broader undo stack of the document in which the monaco editor is embedded. eg. my document would have many monaco editors and when the user invokes undo, it would pick which of the monacos to send that undo request to; but in order to do so correctly, I would need an accurate recording of how many undo stops are being emitted by each of the monaco editors as their models change. For even more context, see here.