Added SCI_GETUNDOSEQUENCE

21 views
Skip to first unread message

Neil Hodgson

unread,
Jul 27, 2024, 8:15:44 PMJul 27
to Scintilla mailing list
A new API SCI_GETUNDOSEQUENCE has been added to Scintilla which returns the current nesting depth of undo actions.

This is mainly for debugging. Every time an application calls SCI_BEGINUNDOACTION to start an undo action, it must call SCI_ENDUNDOACTION when the action is complete. If the application fails to call SCI_ENDUNDOACTION, perhaps because of an exception or other unexpected situation, then the undo sequence will continue. This may lead to many user actions being undone by a single undo command. A trace of SCI_GETUNDOSEQUENCE can help uncover the problem.

Unbalanced undo actions can be even more of a problem when an application supports plugins or user scripts that may contain bugs. The application could display a warning if a script doesn't call SCI_ENDUNDOACTION indicated by a positive SCI_GETUNDOSEQUENCE after returning. In some circumstances, it may be reasonable to reset the nesting level by calling SCI_ENDUNDOACTION until SCI_GETUNDOSEQUENCE returns 0.

There may be a better name for this API. SCI_GETUNDOSEQUENCEDEPTH is a bit closer to what it does but I wanted to emphasize its role in revealing if there is an active undo sequence.

Neil
Reply all
Reply to author
Forward
0 new messages