An editor or software engineering tool may be configured to represent
program code as a doubly-linked list of lexical tokens and to maintain,
coincident with an operation that modifies contents of the list, an undo
object that identifies opposing end nodes of a sublist of one or more
lexical tokens corresponding to a substring that is either inserted into
or removed from the list by the operation. In this way, lexical tokens
corresponding to an inserted substring can be readily and efficiently
excised to restore a pre-insertion tokenized list state. Similarly,
lexical tokens corresponding to a removed substring can be readily and
efficiently reinstated to restore a pre-deletion tokenized list state.
Advantageously, undo support once employed to restore a prior tokenized
list state is symmetrically available to support redo operations. In some
embodiments in accordance with the present invention, undo-redo entries
are maintained in an operation ordered set that is traversed to support
one or more operations in either the undo or redo directions. In some
realizations, such an ordered set of undo-redo entries is maintained by,
or in conjunction with, an undo-redo manager.