CoffeeScript Question

Programatically remove entry from Atom's undo stack

I've written a small piece of

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
, 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
and mess with the
? 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 :)

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download