public async System.Threading.Tasks.Task <OpenEditorResult> OpenEditorAndRevealAsync(Uri fileUri, int?scrollTo = null, bool?atTop = false, bool?focus = false) { using (Log.CriticalOperation($"{nameof(OpenEditorAndRevealAsync)} {fileUri} scrollTo={scrollTo}")) { if (scrollTo == null) { return(null); } var scrollToLine = scrollTo.Value; try { var wpfTextView = await AssertWpfTextViewAsync(fileUri); if (wpfTextView != null) { if (atTop == true) { ScrollViewportVerticallyByPixels(wpfTextView, scrollToLine); } else { EnsureTargetSpanVisible(wpfTextView, scrollToLine); } if (focus == true) { wpfTextView.VisualElement.Focus(); } } return(new OpenEditorResult() { Success = wpfTextView != null, VisualElement = wpfTextView?.VisualElement }); } catch (Exception ex) { Log.Error(ex, $"{nameof(OpenEditorAndRevealAsync)} failed for {fileUri}"); return(null); } } }