Beispiel #1
0
        public void TryConvert_TextInputToOleCommandData()
        {
            var textView = CreateTextView("");
            var buffer   = Vim.CreateVimBuffer(textView);

            buffer.SwitchMode(ModeKind.Insert, ModeArgument.None);
            foreach (var cur in KeyInputUtil.VimKeyInputList)
            {
                if (!buffer.InsertMode.IsDirectInsert(cur))
                {
                    continue;
                }

                var oleCommandData = OleCommandData.Empty;
                try
                {
                    Assert.True(OleCommandUtil.TryConvert(cur, out oleCommandData));

                    // We lose fidelity on these keys because they both get written out as numbers
                    // at this point
                    if (VimKeyUtil.IsKeypadKey(cur.Key))
                    {
                        continue;
                    }
                    Assert.True(OleCommandUtil.TryConvert(oleCommandData, out KeyInput converted));
                    Assert.Equal(converted, cur);
                }
                finally
                {
                    oleCommandData.Dispose();
                }
            }
        }
Beispiel #2
0
            public void Exhaustive()
            {
                foreach (var current in KeyInputUtil.VimKeyInputList)
                {
                    if (current.RawChar.IsNone())
                    {
                        continue;
                    }

                    if (VimKeyUtil.IsKeypadKey(current.Key))
                    {
                        continue;
                    }

                    // The 2 special keys which map differently when used by name vs. when
                    // mapped by char.  They are the keys which don't obey this rule
                    if (current.Key == VimKey.Back ||
                        current.Key == VimKey.Delete)
                    {
                        continue;
                    }

                    var keyInput = KeyInputUtil.CharToKeyInput(current.Char);
                    Assert.Equal(current, keyInput);
                }
            }
Beispiel #3
0
        public void TryConvert_TextInputToOleCommandData()
        {
            var textView = EditorUtil.CreateView("");
            var buffer   = EditorUtil.FactoryService.Vim.CreateBuffer(textView);

            buffer.SwitchMode(ModeKind.Insert, ModeArgument.None);
            foreach (var cur in KeyInputUtil.VimKeyInputList)
            {
                if (!buffer.InsertMode.IsTextInput(cur))
                {
                    continue;
                }

                Guid           commandGroup;
                OleCommandData oleCommandData = new OleCommandData();
                KeyInput       converted;
                try
                {
                    Assert.IsTrue(OleCommandUtil.TryConvert(cur, out commandGroup, out oleCommandData));

                    // We lose fidelity on these keys because they both get written out as numbers
                    // at this point
                    if (VimKeyUtil.IsKeypadKey(cur.Key))
                    {
                        continue;
                    }
                    Assert.IsTrue(OleCommandUtil.TryConvert(commandGroup, oleCommandData, out converted));
                    Assert.AreEqual(converted, cur);
                }
                finally
                {
                    OleCommandData.Release(ref oleCommandData);
                }
            }
        }