Neil Hodgson
unread,Jul 27, 2024, 8:15:44 PMJul 27Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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