Ejemplo n.º 1
0
 public void NormalCommandCannotBeUndone()
 {
     Create("cat");
     _buffer.GetRegister(RegisterName.Unnamed).UpdateValue("s");
     _buffer.SwitchMode(ModeKind.Replace, ModeArgument.None);
     _buffer.Process("co");
     _buffer.Process(KeyInputUtil.VimKeyAndModifiersToKeyInput(VimKey.LowerO, KeyModifiers.Control));
     _buffer.Process("P");
     Assert.AreEqual("cost", _textView.GetLine(0).GetText());
     _buffer.Process(VimKey.Back);
     Assert.AreEqual("cost", _textView.GetLine(0).GetText());
 }
Ejemplo n.º 2
0
        private void UpdateForPasteWait(WpfTextChangedEventArgs e)
        {
            Debug.Assert(InPasteWait);

            //            var command = _margin.CommandLineTextBox.Text ?? "";
            var command = _commandText ?? "";// _margin.CommandLineTextBox.Text ?? "";

            if (e.Changes.Count == 1 && command.Length > 0)
            {
                var change = e.Changes.First();
                if (change.AddedLength == 1)
                {
                    // If we are in a paste wait context then attempt to complete it by passing on the
                    // typed char to _vimBuffer.  This will process it as the register
                    var c        = command[change.Offset];
                    var keyInput = KeyInputUtil.CharToKeyInput(c);
                    _vimBuffer.Process(keyInput);

                    // Now we need to update the command line.  During edits the controller is responsible
                    // for manually updating the command line state.  Also we have to keep the caret postion
                    // correct
                    var name = RegisterName.OfChar('c');
                    if (name.IsSome())
                    {
                        var toPaste = _vimBuffer.GetRegister(name.Value).StringValue;
                        var builder = new StringBuilder();
                        builder.Append(command, 0, change.Offset);
                        builder.Append(toPaste);
                        builder.Append(command, change.Offset + 2, command.Length - (change.Offset + 2));
//                        _margin.CommandLineTextBox.Text = builder.ToString();
//                        _margin.CommandLineTextBox.Select(change.Offset + toPaste.Length, 0);
                    }

                    return;
                }
            }

            // The buffer was in a paste wait but the UI isn't in sync for completing
            // the operation.  Just pass Escape down to the buffer so it will cancel out
            // of paste wait and go back to a known state
            _vimBuffer.Process(KeyInputUtil.EscapeKey);
        }
Ejemplo n.º 3
0
        public void TestChar_yy_1()
        {
            _buffer.Process("yy");
            var tss = _textView.TextSnapshot;
            var reg = _buffer.GetRegister(RegisterName.Unnamed);

            Assert.Equal(tss.Lines.ElementAt(0).GetTextIncludingLineBreak(), reg.StringValue);
        }