Hi
I have a list with searchresults, which are positions in files. I have added the snapshot to each result using this snapshot:
ActiveView.CurrentSnapshot.SnapshotRange.SnapShot
After clicking i jump to/select the specific position which works. Then i would like to translate this selection to the new snapshot, which messes up in case other, previous lines are changed in the meantime. Code:
public bool GotoPosition(IEditorPosition position, int selectCharacterCount) {
TextPosition actiPos = new TextPosition(position.Line, position.Column);
TextPosition endPoint = ActiveView.OffsetToPosition(this.ActiveView.PositionToOffset(actiPos) + selectCharacterCount);
this.ActiveView.Selection.SelectRange(actiPos, endPoint);
// reposition if snapshot changed
var ep = (position as EditorPosition);
if (ep != null && ep.SnapShot != null) {
TextRange textRange = ActiveView.Selection.TextRange.Translate(ep.SnapShot, ActiveView.CurrentSnapshot, TextRangeTrackingModes.Default);
ActiveView.Selection.SelectRange(textRange);
}
return true;
}
So, the first SelectRange works, but the correction for changed snapshot messes up.
Can you confirm that a translate can work over more than two versions of snapshots? (When more editing actions have been done)
Can translate handle new line etc, is there a method to Translate an position maybe?
So, in general, do you have a solution for my little problem:)
Thank you in advance,
Greets Martin