Beispiel #1
0
 public void IsWaitingForMoreInput3()
 {
     Create("hello world");
     _runner.Add(VimUtil.CreateLegacyBinding("cat", (count, reg) => CommandResult.NewCompleted(ModeSwitch.NoSwitch)));
     Assert.IsTrue(Run("cat").IsComplete);
     Assert.IsFalse(_runner.IsWaitingForMoreInput);
 }
Beispiel #2
0
 public void Run_NoMatchingCommand2()
 {
     Create("hello world");
     _runner.Add(VimUtil.CreateLegacyBinding("cat", (count, reg) => CommandResult.NewCompleted(ModeSwitch.NoSwitch)));
     Assert.IsTrue(_runner.Run('c').IsNeedMoreInput);
     Assert.IsTrue(_runner.Run('b').IsError);
 }
Beispiel #3
0
 public void KeyRemapMode_NoneWhileFindingCommand()
 {
     Create("hello world");
     _runner.Add(VimUtil.CreateLegacyBinding("cat"));
     _runner.Run('c');
     Assert.IsTrue(_runner.KeyRemapMode.IsNone());
 }
Beispiel #4
0
        public void Run_MotionMixedWithNonMotion()
        {
            Create("the dog chased the ball");
            var simple = new[] { "g~g~", "g~~", "gugu", "guu", "gUgU", "gUU" };
            var motion = new[] { "g~", "gu", "gU" };

            foreach (var cur in simple)
            {
                _runner.Add(VimUtil.CreateLegacyBinding(cur));
            }

            foreach (var cur in motion)
            {
                _runner.Add(VimUtil.CreateMotionBinding(cur));
            }

            foreach (var cur in simple)
            {
                // Make sure we can run them all
                Assert.IsTrue(_runner.Run(cur).IsComplete);
            }

            foreach (var cur in motion)
            {
                // Make sure we can run them all
                Assert.IsTrue(_runner.Run(cur).IsNeedMoreInput);
                _runner.ResetState();
            }
        }
Beispiel #5
0
        public void Add3()
        {
            Create(String.Empty);
            var command1 = VimUtil.CreateLegacyBinding("foo", (x, y) => CommandResult.NewCompleted(ModeSwitch.NoSwitch));

            _runner.Add(command1);
            _runner.Add(command1);
        }
Beispiel #6
0
 public void KeyRemapMode_OperatorPendingWhenAmbiguousBetweenMotionAndCommand()
 {
     Create("hello world");
     _runner.Add(VimUtil.CreateMotionBinding("d"));
     _runner.Add(VimUtil.CreateLegacyBinding("dd"));
     _runner.Run('d');
     Assert.IsTrue(_runner.KeyRemapMode.IsSome(KeyRemapMode.OperatorPending));
 }
Beispiel #7
0
        public void Add1()
        {
            Create(String.Empty);
            var command1 = VimUtil.CreateLegacyBinding("foo", (x, y) => CommandResult.NewCompleted(ModeSwitch.NoSwitch));

            _runner.Add(command1);
            Assert.AreSame(command1, _runner.Commands.Single());
        }
Beispiel #8
0
        public void Remove1()
        {
            Create(String.Empty);
            var command1 = VimUtil.CreateLegacyBinding("foo", (x, y) => CommandResult.NewCompleted(ModeSwitch.NoSwitch));

            _runner.Add(command1);
            _runner.Remove(command1.KeyInputSet);
            Assert.AreEqual(0, _runner.Commands.Count());
        }
Beispiel #9
0
 public void Reset1()
 {
     Create("hello world");
     _runner.Add(VimUtil.CreateLegacyBinding("abc", (x, y) => CommandResult.NewCompleted(ModeSwitch.NoSwitch)));
     Run("a");
     Assert.IsTrue(_runner.IsWaitingForMoreInput);
     _runner.ResetState();
     Assert.IsFalse(_runner.IsWaitingForMoreInput);
 }
Beispiel #10
0
        public void Run_CommandMatch2()
        {
            Create(String.Empty);
            var count1 = 0;

            _runner.Add(VimUtil.CreateLegacyBinding("a", (count, reg) => { count1++; return(CommandResult.NewCompleted(ModeSwitch.NoSwitch)); }));
            Run("b");
            Assert.AreEqual(0, count1);
        }
Beispiel #11
0
        public void Run_Count4()
        {
            Create(string.Empty);
            var didRun = false;

            _runner.Add(VimUtil.CreateLegacyBinding("a", (count, reg) => { didRun = true; }));
            Assert.IsTrue(_runner.Run('0').IsError);
            Assert.IsFalse(didRun);
        }
Beispiel #12
0
        public void Add2()
        {
            Create(String.Empty);
            var command1 = VimUtil.CreateLegacyBinding("foo", (x, y) => CommandResult.NewCompleted(ModeSwitch.NoSwitch));
            var command2 = VimUtil.CreateLegacyBinding("bar", (x, y) => CommandResult.NewCompleted(ModeSwitch.NoSwitch));

            _runner.Add(command1);
            _runner.Add(command2);
            Assert.AreEqual(2, _runner.Commands.Count());
            Assert.IsTrue(_runner.Commands.Contains(command1));
            Assert.IsTrue(_runner.Commands.Contains(command2));
        }
Beispiel #13
0
        public void Run_CommandMatch7()
        {
            Create("foo bar");
            var count1 = 0;

            _runner.Add(VimUtil.CreateMotionBinding("aa", data => { count1++; return(NormalCommand.NewYank(data)); }));
            var count2 = 0;

            _runner.Add(VimUtil.CreateLegacyBinding("aab", (count, reg) => { count2++; return(CommandResult.NewCompleted(ModeSwitch.NoSwitch)); }));
            Run("aaw");
            Assert.AreEqual(1, count1);
            Assert.AreEqual(0, count2);
        }
Beispiel #14
0
        public void Run_Count1()
        {
            Create(String.Empty);
            var didRun = false;

            _runner.Add(VimUtil.CreateLegacyBinding("a", (count, reg) =>
            {
                Assert.IsTrue(count.IsNone());
                didRun = true;
                return(CommandResult.NewCompleted(ModeSwitch.NoSwitch));
            }));
            Run("a");
            Assert.IsTrue(didRun);
        }
Beispiel #15
0
        public void Run_Register3()
        {
            Create(String.Empty);
            var didRun = false;

            _runner.Add(VimUtil.CreateLegacyBinding("a", (count, reg) =>
            {
                Assert.AreSame(_registerMap.GetRegister('d'), reg);
                didRun = true;
                return(CommandResult.NewCompleted(ModeSwitch.NoSwitch));
            }));
            Run("\"da");
            Assert.IsTrue(didRun);
        }
Beispiel #16
0
        public void Run_Register1()
        {
            Create(String.Empty);
            var didRun = false;

            _runner.Add(VimUtil.CreateLegacyBinding("a", (count, reg) =>
            {
                Assert.AreEqual(RegisterName.Unnamed, reg.Name);
                didRun = true;
                return(CommandResult.NewCompleted(ModeSwitch.NoSwitch));
            }));
            Run("a");
            Assert.IsTrue(didRun);
        }
Beispiel #17
0
        public void CommandRan3()
        {
            Create("hello world");
            var didSee   = false;
            var command1 = VimUtil.CreateLegacyBinding("cat", (x, y) => CommandResult.NewCompleted(ModeSwitch.NoSwitch));

            _runner.Add(command1);
            _runner.CommandRan += (notUsed, tuple) =>
            {
                didSee = true;
            };
            _runner.Run('c');
            _runner.Run(KeyInputUtil.EscapeKey);
            Assert.IsFalse(didSee);
        }
Beispiel #18
0
        public void CommandRan2()
        {
            Create("hello world");
            var didSee   = false;
            var command1 = VimUtil.CreateLegacyBinding("c", (x, y) => CommandResult.NewCompleted(ModeSwitch.NoSwitch));

            _runner.Add(command1);
            _runner.CommandRan += (notUsed, tuple) =>
            {
                Assert.AreSame(command1, tuple.CommandBinding);
                didSee = true;
            };
            _runner.Run('2');
            _runner.Run('c');
            Assert.IsTrue(didSee);
        }