
Hi,
when we open an editor instance with a specific selection, the view is not scrolled. So the selection might not be visible when the document is opened. When we change the selection after the view is loaded, the view is scrolled to make the selection visible.
As a workaround we reset the selection after the view is loaded, but I think the SyntaxEditor component should automatically scroll the view to make sure the selection is visible.
private void OnViewLoaded()
{
MakeSureSelectionIsVisible();
}
private void MakeSureSelectionIsVisible()
{
var selection = SyntaxEditor.ActiveView.Selection;
var selectedRange = selection.TextRange;
if (SyntaxEditor.ActiveView.VisibleViewLines.SnapshotRange.Contains(selectedRange))
{
return;
}
// To force that selection becomes visible, we have to change the selection first. Otherwise nothing happens.
selection.MoveToDocumentStart();
selection.SelectRange(selectedRange);
}
Best regards, Tobias Lingemann.