Closed jakobhellermann closed 1 year ago
I just noticed this also fixes the bug (?) where typing EndStunPause<Ctrl-Z>
will remove the entire string instead of just leaving you with EndStunPaus
.
If that is a bug and not a feature. If it's a feature then I can re-add the '|| cmd is InsertCharCommand`.
Fixes a bug where you need to redo twice to actually redo one atomic change.
For background, when typing
U
on1,R
there will be three commands pushed to the undo buffer:autoundo
means that when a command is undone, if the next one isautoundo
then it will also be undone. This letsCtrl-Z
treat these three commands as one single undo operation.This works for undoing, but notice the
autoundo=False
in theInsertCharCommand
above, which was previouslyTrue
.This happened because
ClearSelectedCommand
triggersOnTextChanging
which triggersStudio.UpdateLines
which attempts to change the text with some commands. During anundo
, commands are disabled, so nothing happens here, but while trying to run a commandStudio.UpdateLines
callsBeginAutoUndoCommands
andEndAutoUndoCommands
, which leads to the topmost command in the history settingautoUndo=false
.This is a problem because now the redo stack is
so when you redo, the autoundo chain is broken immediately at
InsertCharCommand
, so you need to redo again for the remaining two.The solution is to do nothing in
BeginAutoUndoCommands
/EndAutoUndoCommands
if commands are currently disabled.The only reason this is not currently broken for undos is that there the logic does
which I would guess was added to fix this bug, but it would also be needed at the
Redo
.By fixing the root cause we can remove the
|| cmd is InsertCharCommand
(as long as I didn't miss anything else it is important for).