Beispiel #1
0
        private TextViewMock SetupTextView(string content, int startLineNumber, int startColumn)
        {
            var document = new EditorDocumentMock(content);
            var tv       = new TextViewMock(document.TextBuffer());
            var line     = document.EditorBuffer.CurrentSnapshot.GetLineFromLineNumber(startLineNumber);

            tv.Caret.MoveTo(new SnapshotPoint(tv.TextBuffer.CurrentSnapshot, line.Start + startColumn));
            return(tv);
        }
        private void GetPeekableItems(string content, int position, IList <IPeekableItem> items, ITextRange selection = null)
        {
            var document = new EditorDocumentMock(content, @"C:\file.r");
            var textView = new TextViewMock(document.TextBuffer(), position);

            if (selection != null)
            {
                textView.Selection.Select(new SnapshotSpan(document.TextBuffer().CurrentSnapshot, new Span(selection.Start, selection.Length)), isReversed: false);
                textView.Caret.MoveTo(new SnapshotPoint(textView.TextBuffer.CurrentSnapshot, selection.End));
            }
            else
            {
                textView.Caret.MoveTo(new SnapshotPoint(textView.TextBuffer.CurrentSnapshot, position));
            }

            var peekSession = PeekSessionMock.Create(textView, position);
            var factory     = PeekResultFactoryMock.Create();
            var peekSource  = new PeekableItemSource(textView.TextBuffer, factory, _services);

            peekSource.AugmentPeekSession(peekSession, items);
        }