public IWpfTextView GetTextView() { if (_textView == null) { TestWorkspace.ResetThreadAffinity(); WpfTestCase.RequireWpfFact($"Creates an IWpfTextView through {nameof(TestHostDocument)}.{nameof(GetTextView)}"); var factory = _exportProvider.GetExportedValue <ITextEditorFactoryService>(); // Every default role but outlining. Starting in 15.2, the editor // OutliningManager imports JoinableTaskContext in a way that's // difficult to satisfy in our unit tests. Since we don't directly // depend on it, just disable it var roles = factory.CreateTextViewRoleSet(PredefinedTextViewRoles.Analyzable, PredefinedTextViewRoles.Document, PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable); _textView = factory.CreateTextView(this.TextBuffer, roles); if (this.CursorPosition.HasValue) { _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, CursorPosition.Value)); } else if (this.SelectedSpans.IsSingle()) { var span = this.SelectedSpans.Single(); _textView.Selection.Select(new SnapshotSpan(_textView.TextSnapshot, new Span(span.Start, span.Length)), false); } } return(_textView); }
public IWpfTextView GetTextView() { if (_textView == null) { TestWorkspace.ResetThreadAffinity(); _textView = _exportProvider.GetExportedValue <ITextEditorFactoryService>().CreateTextView(this.TextBuffer); if (this.CursorPosition.HasValue) { _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, CursorPosition.Value)); } else if (this.SelectedSpans.IsSingle()) { var span = this.SelectedSpans.Single(); _textView.Selection.Select(new SnapshotSpan(_textView.TextSnapshot, new Span(span.Start, span.Length)), false); } } return(_textView); }