Example #1
0
        public void QueryStatus_Reshaper_BackspaceAsCommand()
        {
            var backKeyInput = KeyInputUtil.VimKeyToKeyInput(VimKey.Back);
            var count        = 0;

            _buffer.KeyInputProcessed += delegate { count++; };
            _buffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(true).Verifiable();
            Assert.True(_buffer.CanProcessAsCommand(backKeyInput));
            Assert.False(RunQueryStatus(backKeyInput));
            Assert.True(_bufferCoordinator.DiscardedKeyInput.IsSome(backKeyInput));
            Assert.Equal(1, count);
            _factory.Verify();
        }
Example #2
0
        private bool TryProcess(KeyEventArgs e, KeyInput keyInput)
        {
            if (KeyEventIsDeadChar(e))
            {
                // When a dead key combination is pressed we will get the key down events in
                // sequence after the combination is complete.  The dead keys will come first
                // and be followed the final key which produces the char.  That final key
                // is marked as DeadCharProcessed.
                //
                // All of these should be ignored.  They will produce a TextInput value which
                // we can process in the TextInput event
                return(false);
            }

            if ((_vimBuffer.ModeKind.IsAnyInsert() || _vimBuffer.ModeKind.IsAnySelect()) &&
                !_vimBuffer.CanProcessAsCommand(keyInput) &&
                keyInput.Char > 0x1f &&
                _vimBuffer.BufferedKeyInputs.IsEmpty &&
                !_vimBuffer.Vim.MacroRecorder.IsRecording)
            {
                return(false);
            }

            if (_completionBroker.IsCompletionActive(_textView) && !IsEscapeKey(e))
            {
                return(false);
            }

            if (_signatureHelpBroker.IsSignatureHelpActive(_textView) && !IsEscapeKey(e))
            {
                return(false);
            }

            if (_inlineRenameListenerFactory.InRename)
            {
                return(false);
            }

            if (_vimBuffer.ModeKind.IsAnyInsert() && e.Characters == "\t")
            {
                // Allow tab key to work for snippet completion
                //
                // TODO: We should only really do this when the characters
                // to the left of the caret form a valid snippet
                return(false);
            }

            return(_vimBuffer.CanProcess(keyInput) && _vimBuffer.Process(keyInput).IsAnyHandled);
        }
Example #3
0
 public void CanProcessAsCommand_Command()
 {
     _vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
     Assert.IsTrue(_vimBuffer.CanProcessAsCommand('a'));
 }
Example #4
0
        /// <summary>
        /// Helper for the CanProcessAsCommand function which maps the VimKey to a KeyInput value
        /// </summary>
        public static bool CanProcessAsCommand(this IVimBuffer buffer, VimKey key)
        {
            var keyInput = KeyInputUtil.VimKeyToKeyInput(key);

            return(buffer.CanProcessAsCommand(keyInput));
        }
Example #5
0
        /// <summary>
        /// Helper for the CanProcessAsCommand function which maps the char to a KeyInput value
        /// </summary>
        public static bool CanProcessAsCommand(this IVimBuffer buffer, char c)
        {
            var keyInput = KeyInputUtil.CharToKeyInput(c);

            return(buffer.CanProcessAsCommand(keyInput));
        }
Example #6
0
 /// <summary>
 /// Try and process the given KeyInput with the IVimBuffer as a command.  This is called
 /// from situations where we have to guess at the KeyInput a bit.  It may be a key in a
 /// multi-key character and hence we only want to process if it's bound to a command
 ///
 /// This is overridable by derived classes in order for them to prevent any KeyInput from
 /// reaching the IVimBuffer
 /// </summary>
 protected virtual bool TryProcessAsCommand(KeyInput keyInput)
 {
     return(_buffer.CanProcessAsCommand(keyInput) && _buffer.Process(keyInput).IsAnyHandled);
 }
Example #7
0
 public void CanProcessAsCommand_KeypadDivide()
 {
     _vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
     Assert.True(_vimBuffer.CanProcessAsCommand(VimKey.KeypadDivide));
 }