コード例 #1
0
        /// <summary>
        /// True if the binding is applicable to a text view
        /// </summary>
        private bool IsTextViewBinding(CommandKeyBinding binding)
        {
            switch (_scopeData.GetScopeKind(binding.KeyBinding.Scope))
            {
            case ScopeKind.TextEditor:
            case ScopeKind.Global:
                return(true);

            default:
                return(false);
            }
        }
コード例 #2
0
 /// <summary>
 /// Get conflicting key bindings stored in our application settings
 /// </summary>
 private void GetKeyBindings()
 {
     // Construct a list of all fallback commands keys we had to unbind.
     // We are only interested in the bindings scoped to text views and global.
     _fallbackCommandList = _vimApplicationSettings.RemovedBindings
                            .Where(binding => IsTextViewBinding(binding))
                            .Select(binding => new FallbackCommand(
                                        _scopeData.GetScopeKind(binding.KeyBinding.Scope),
                                        KeyBinding.Parse(binding.KeyBinding.CommandString),
                                        binding.Id
                                        ))
                            .ToLookup(fallbackCommand => fallbackCommand.KeyBindings[0].Char);
 }
コード例 #3
0
ファイル: KeyBindingService.cs プロジェクト: zbecknell/VsVim
        /// <summary>
        /// Should this be skipped when removing conflicting bindings?
        /// </summary>
        internal bool ShouldSkip(CommandKeyBinding binding)
        {
            var scope = binding.KeyBinding.Scope;

            if (!_includeAllScopes && (_scopeData.GetScopeKind(scope) == ScopeKind.Unknown || _scopeData.GetScopeKind(scope) == ScopeKind.SolutionExplorer))
            {
                return(true);
            }

            if (!binding.KeyBinding.KeyStrokes.Any())
            {
                return(true);
            }

            var first = binding.KeyBinding.FirstKeyStroke;

            // We don't want to remove any mappings which don't include a modifier key
            // because it removes too many mappings.  Without this check we would for
            // example remove Delete in insert mode, arrow keys for intellisense and
            // general navigation, space bar for completion, etc ...
            //
            // One exception is function keys.  They are only bound in Vim to key
            // mappings and should win over VS commands since users explicitly
            // want them to occur
            if (first.KeyModifiers == VimKeyModifiers.None && !first.KeyInput.IsFunctionKey)
            {
                return(true);
            }

            // In Vim Ctrl+Shift+f is exactly the same command as ctrl+f.  Vim simply ignores the
            // shift key when processing a control command with an alpha character.  Visual Studio
            // though does differentiate.  Ctrl+f is different than Ctrl+Shift+F.  So don't
            // process any alpha commands which have both Ctrl and Shift as Vim wouldn't
            // ever hit them
            if (char.IsLetter(first.Char) && first.KeyModifiers == (VimKeyModifiers.Shift | VimKeyModifiers.Control))
            {
                return(true);
            }

            return(false);
        }