I would like to have an option to set the caret in the current textview AND scroll to the caret.
Setting the caret is already possible:
await clientContext.Extensibility.Editor().EditAsync(batch =>
{
var caret = new TextPosition(textDocumentSnapshot, position);
textViewSnapshot!.AsEditable(batch).SetSelections(
[
new Selection(activePosition: caret, anchorPosition: caret, insertionPosition: caret)
]);
},
cancellationToken);
But I can't find a way to programmatically scroll to the caret.
In the old extensibility model I could do:
var documentView = await VS.Documents.GetActiveDocumentViewAsync();
var line = documentView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(...);
documentView.TextView.Selection.Select(line.Extent, false);
documentView.TextView.ViewScroller.EnsureSpanVisible(line.Extent, EnsureSpanVisibleOptions.AlwaysCenter);
I want to use this in my CodeNav extension which shows a list of methods, properties, etc... clicking an item now sets the selection but it should also scroll to the caret, so that the user can quickly navigate all code elements in a document.
I would like to have an option to set the caret in the current textview AND scroll to the caret.
Setting the caret is already possible:
But I can't find a way to programmatically scroll to the caret.
In the old extensibility model I could do:
I want to use this in my CodeNav extension which shows a list of methods, properties, etc... clicking an item now sets the selection but it should also scroll to the caret, so that the user can quickly navigate all code elements in a document.