
Hi,
i´m applying a textchange on the current editorline. This change replaces the text of the whole line. If the cursor is inside the replaced range its postion is lost and the caret moved to the end of the (replaced) line.
I tried to save the old cursor position by creating a TextSnapshotRange using the old snapshot and the cursors offset:After applying the change I tried to translate that range to the current snapshot and set the cursors offset:
This solution doesn´t work. Any ideas how to solve this?
Thanks in advance.
i´m applying a textchange on the current editorline. This change replaces the text of the whole line. If the cursor is inside the replaced range its postion is lost and the caret moved to the end of the (replaced) line.
I tried to save the old cursor position by creating a TextSnapshotRange using the old snapshot and the cursors offset:
TextSnapshotRange range = new TextSnapshotRange(oldsnapshot, editor.Caret.Offset);
range = range.TranslateTo(editor.Document.CurrentSnapshot, TextRangeTrackingModes.Default);
editor.Caret.Offset = range.StartOffset;
Thanks in advance.