In my application, when the user makes certain changes via the UI, I rewrite a portion of the code in the editor for them. Because of the nature of the changes I'm making, it's much easier to replace the entire text in the editor than to make the changes piecemeal within the document.
I originally tried replacing the text by setting the Text property, but that didn't seem to add the change to the Undo list. Since I want this change to participate in the undo/redo chain, I then figured I need to use Document.ReplaceText to make my change. I've done so and it seemed to fix the problem of the change not appearing in the Undo list.
Question #1) is this the preferred way of replacing the entire text of the document in an 'undoable' operation?
Now, things seem to work ok with undo / redo, except that I've noticed that when I undo a change, the entire text of the document gets selected automatically. I've figured out how to unselect this text by just doing Collapse() on the selection, but it causes a bit of flicker. Before I go about looking for beginupdate / endupdate type functionality in the editor (I'm sure it's there), I wanted to ask if this is the desired behavior of Undo and whether there are any properties to control it, so here goes:
Question #2) should Undo select the text in the buffer, following the undo of an operation that replaced all the text in the buffer? If so, what is the preferred way of preventing the text from being selected without flicker in the UI, as my UI does not desire this behavior?
Thanks,
I originally tried replacing the text by setting the Text property, but that didn't seem to add the change to the Undo list. Since I want this change to participate in the undo/redo chain, I then figured I need to use Document.ReplaceText to make my change. I've done so and it seemed to fix the problem of the change not appearing in the Undo list.
Question #1) is this the preferred way of replacing the entire text of the document in an 'undoable' operation?
Now, things seem to work ok with undo / redo, except that I've noticed that when I undo a change, the entire text of the document gets selected automatically. I've figured out how to unselect this text by just doing Collapse() on the selection, but it causes a bit of flicker. Before I go about looking for beginupdate / endupdate type functionality in the editor (I'm sure it's there), I wanted to ask if this is the desired behavior of Undo and whether there are any properties to control it, so here goes:
Question #2) should Undo select the text in the buffer, following the undo of an operation that replaced all the text in the buffer? If so, what is the preferred way of preventing the text from being selected without flicker in the UI, as my UI does not desire this behavior?
Thanks,
Kelly Leahy Software Architect Milliman, USA