Reputation: 518
I've written a small piece of coffeescript
code for Atom editor to update a timestamp comment on certain files just before they are saved, and it works perfectly.
Unfortunately, this modification ends up, obviously, on Atom's undo stack, so if after saving these files I undo my changes, the timestamp is undone before the previous changes. For this reason I want to remove this timestamp update from the undo stack.
I know I can pack multiple changes into a single undo transaction using TextBuffer.transact()
or TextEditor.transact()
, but I can't find how to just remove last entry (or entries) from the undo stack.
Is the only solution to access directly the historyProvider
and mess with the undostack
Array
? Frankly, right now I don't know which side-effects this can have, but I don't find anything in Atom API todo what I need.
Thanks a lot in advance, as always :)
Upvotes: 0
Views: 51
Reputation: 518
Sorry for the auto-answer, but I found a way of achieving what I want.
Using Editor.insertText(text, {undo: 'skip'}
, a text insertion can be removed from the undo stack, and the same option can be provided for setTextInRange
, which is what I was using previously.
Upvotes: 0