How can I hide programmatic text changes from the undo list?

SyntaxEditor for Windows Forms Forum

Posted 10 years ago by Craig - Varigence, Inc.
Version: 4.0.0282
Avatar
I have a scenario where text changes can occur programmatically and non-programmatically and I only want the undo list to include non-programmatic changes.

For programmatic changes, I'm updating my document's Text via the Document.Text property. That works too well considering that it clears the undo list.

While I can use ReplaceText() instead, that's a problem since all text changes are now added, not just changes from user typing.

Is there some way to limit the undo list to only add non-programmatic changes? Could I store the undo/redo lists before the change and re-apply them after? Is there a handler that would let me intercept the undo list change behavior? Does the WPF Control behave differently?

Thanks,

-Craig

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Craig,

All document text changes have to be undoable, otherwise the undo stack could become corrupted. I don't think any of the things you were suggesting would work.

The only thing I can think of is that you use ReplaceText for programmatic updates and in your undo lists maybe filter them to not show undoable modifications of a certain type (like Custom). Then replace our built-in undo/redo to use custom ones that undo back to the next non-programmatic undoable modification.

However note that when you undo back to the last non-programmatic modification, you will also undo any programmatic ones since. I'm not sure if that is a problem or not for you. If it is, sorry but I'm not sure anything would work for you due to the undoable nature of all text changes.


Actipro Software Support

Posted 10 years ago by Craig - Varigence, Inc.
Avatar
So, my setup is that I have a separate undo/redo stack for programmatic changes. The undo/redo list that the user sees combines the notifications from the editor with the programmatic stack (hence why I don't want the editor capturing programmatic changes).

I'm trying to workaround it by storing the programmatic editor changes but keeping their ViewModels collapsed in my visible undo stack. When I hit one during an undo, I have the editor simply undo it without the user realizing it.

One lingering issue, however, is that undo'ing a programmatic change causes a SelectAll operation to occur within the editor. Is there a way to prevent this unintended select all operation?

Thanks again,

-Craig

[Modified at 08/18/2009 01:09 AM]
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Craig,

Perhaps if you use the DocumentModificationFlags.RetainSelection flag when adding your modifications, that would help.


Actipro Software Support

The latest build of this product (v2018.1 build 0342) was released 11 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.