Ejemplo n.º 1
0
 public void TypeForwardShouldReplace()
 {
     Create("hello world");
     _buffer.SwitchMode(ModeKind.Replace, ModeArgument.None);
     _buffer.Process("again");
     Assert.AreEqual("again world", _textView.GetLine(0).GetText());
     Assert.AreEqual(5, _textView.GetCaretPoint().Position);
 }
Ejemplo n.º 2
0
        public void JumpLineLastWithNoWhiteSpace()
        {
            Create("dog", "cat", "tree");
            RunCommand("$");
            var tss  = _textView.TextSnapshot;
            var last = tss.GetLineFromLineNumber(tss.LineCount - 1);

            Assert.AreEqual(last.Start, _textView.GetCaretPoint());
        }
Ejemplo n.º 3
0
 public void Repeat_Insert()
 {
     Create("the cat");
     _buffer.SwitchMode(ModeKind.Insert, ModeArgument.NewInsertWithCount(2));
     _buffer.Process("hi");
     Assert.AreEqual(2, _textView.GetCaretPoint().Position);
     _buffer.Process(VimKey.Escape);
     Assert.AreEqual("hihithe cat", _textView.GetLine(0).GetText());
     Assert.AreEqual(3, _textView.GetCaretPoint().Position);
 }
Ejemplo n.º 4
0
 public void Record_InsertTextAndEscape()
 {
     Create("");
     _buffer.Process("qcidog");
     _buffer.Process(VimKey.Escape);
     _buffer.Process("q");
     Assert.AreEqual(ModeKind.Normal, _buffer.ModeKind);
     _textView.MoveCaretTo(0);
     _buffer.Process("@c");
     Assert.AreEqual("dogdog", _textView.GetLine(0).GetText());
     Assert.AreEqual(ModeKind.Normal, _buffer.ModeKind);
     Assert.AreEqual(2, _textView.GetCaretPoint().Position);
 }
Ejemplo n.º 5
0
        bool InvokeChain(Action <ChainedKeyProcessor, ITextBuffer, Action> invoker)
        {
            bool   handled = true;
            int    index   = -1;
            Action next    = null;

            next = delegate {
                while (++index < keyProcessorProviders.Count)
                {
                    var targetPoint = wpfTextView.GetCaretPoint(s =>
                                                                keyProcessorProviders[index].Metadata.ContentTypes.Any(s.ContentType.IsOfType)
                                                                );
                    // If the cursor is not in the right buffer, skip this processor.
                    if (targetPoint == null)
                    {
                        continue;
                    }
                    invoker(
                        keyProcessorProviders[index].Value.GetProcessor(wpfTextView),
                        targetPoint.Value.Snapshot.TextBuffer,
                        next
                        );
                    // After invoking the method, stop.  If it calls next(), we'll continue the chain.
                    return;
                }
                // If we got here, we reached the end of the chain without any handler consuming the event.
                handled = false;
            };
            next();
            return(handled);
        }
Ejemplo n.º 6
0
        public void CustomProcess_Back()
        {
            Create("world", "");
            _vimBuffer.InsertMode.CustomProcess(
                KeyInputUtil.VimKeyToKeyInput(VimKey.Back),
                () =>
            {
                _textBuffer.Insert(0, "hello ");
                return(true);
            });

            Assert.AreEqual("hello world", _textView.GetLine(0).GetText());
            _vimBuffer.Process(VimKey.Escape);

            // Now ensure it repeats properly
            _textView.MoveCaretTo(2);
            _vimBuffer.Process(".");
            Assert.AreEqual("hllo world", _textView.GetLine(0).GetText());
            Assert.AreEqual(0, _textView.GetCaretPoint().Position);
        }
Ejemplo n.º 7
0
 public void ResetCaretFromShiftLeft1()
 {
     Create("  hello", "  world");
     EnterMode(_textView.GetLineRange(0, 1).Extent);
     _buffer.Process("<");
     Assert.AreEqual(0, _textView.GetCaretPoint().Position);
 }
Ejemplo n.º 8
0
 public void Change_LineWise()
 {
     Create("cat", "  dog", "  bear", "tree");
     EnterMode(ModeKind.VisualLine, _textView.GetLineRange(1, 2).ExtentIncludingLineBreak);
     _buffer.LocalSettings.AutoIndent = true;
     _buffer.Process("c");
     Assert.AreEqual("cat", _textView.GetLine(0).GetText());
     Assert.AreEqual("", _textView.GetLine(1).GetText());
     Assert.AreEqual("tree", _textView.GetLine(2).GetText());
     Assert.AreEqual(2, _textView.Caret.Position.VirtualBufferPosition.VirtualSpaces);
     Assert.AreEqual(_textView.GetLine(1).Start, _textView.GetCaretPoint());
     Assert.AreEqual(ModeKind.Insert, _buffer.ModeKind);
 }