Say I have this file:
aaa bbb ccc
aaa bbb ccc
aaa $|xxx ccc
$|
denotes the selection (1 selection), where |
is the caret.
My plugin performs the following steps:
First, it changes the selection like this:
|aaa bbb ccc
aaa bbb ccc
aaa $xxx ccc
Then, it executes right_delete
. These two operations are executed from a parent TextCommand
that drives the whole process.
If I undo the deletion, I end up with this:
aaa bbb ccc
aaa bbb ccc
aaa $|xxx ccc
In other words, I’m exactly where I was at the beginning.
However, I want to end up in this state when I undo:
$|aaa bbb ccc
aaa bbb ccc
aaa xxx ccc
I have tried using mark_undo_groups_for_gluing
…glue_marked_undo_groups
after my selection and before the delete operation. I’ve also tried making the selection changes in a separate TextCommand
, but neither method will work.
While investigating, it seems that even soft_undo
skips over my selection change.
Is there any way in which I can tell Sublime “ignore all previous selection changes in this undo group and use the current selection when undoing”? For example, is there a select
command that contributes a separate undo step to the undo stack? (Just an example.)
I think I’ve ran out of ideas how to achieve this.