One-line edition mode during debug

SyntaxEditor for WPF Forum

Posted 9 years ago by Valéry Sablonnière - Staubli
Version: 15.1.0623


in our code editor, when we are in debug mode, the whole editor is read-only,
but the user can enter in "edit mode" and can modify one line. When this line
has been edited, he can commit his changes or cancel them.
If he commits his changes, the whole document goes back to read-only, if he
cancels them, the line edited is restored.

To do this, I use a ReadOnlyIndicatorTagger and an EditIndicatorTagger with an
EditIndicatorTag retaining the text of the line when the user enters in
"Edit mode".
When he cancels the changes, I replace the range of the line with the text
contained in the EditIndicatorTag.

But there are several issues with this solution:
- when the changes are canceled, all the indicators of this line disappear
- all changes made during the "Edit mode", are kept in the Undo stack

What do you recommend to fix this ?

Best regards,

Comments (1)

Answer - Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA


As long as you ensure your undo stack always has a large enough capacity, you could call editor.Document.UndoHistory.Undo() while UndoHistory.CanUndo is true.  Then perhaps call UndoHistory.Clear() once you commit anything.  That should help keep the undo stack clear and will keep indicators around too.  You might need to adjust indicators a tad though since their ranges don't track in the undo history.

Actipro Software Support

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.