示例#1
0
        protected IWpfTextView CreateTextView(TestText inputText, int selectionStartLine, int selectionStartColumn,
                                              int?selectionEndLine, int?selectionEndColumn)
        {
            var          textBuffer = VsxStubObjects.CreateTextBuffer(inputText.ToString());
            IWpfTextView textView   = new StubWpfTextView(textBuffer);

            if (selectionEndColumn != null && selectionEndLine != null)
            {
                textView.Selection.Select(new SnapshotSpan(
                                              inputText.GetSnapshotPoint(textView.TextSnapshot, selectionStartLine, selectionStartColumn),
                                              inputText.GetSnapshotPoint(textView.TextSnapshot, selectionEndLine.Value, selectionEndColumn.Value)),
                                          false);
            }

            int caretLine   = selectionEndLine ?? selectionStartLine;
            int caretColumn = selectionEndColumn ?? selectionStartColumn;

            textView.Caret.MoveTo(inputText.GetSnapshotPoint(textView.TextSnapshot, caretLine, caretColumn));
            return(textView);
        }