Ejemplo n.º 1
0
 /// <summary>
 /// Returns the list of commands that were previously removed by the user and are no longer currently active.
 /// </summary>
 internal List <CommandKeyBinding> FindRemovedKeyBindings(CommandListSnapshot commandListSnapshot)
 {
     return(_vimApplicationSettings
            .RemovedBindings
            .Where(x => !commandListSnapshot.IsActive(x))
            .ToList());
 }
Ejemplo n.º 2
0
        private void Create(params string[] args)
        {
            _dte = MockObjectFactory.CreateDteWithCommands(args);
            _commandListSnapshot = new CommandListSnapshot(_dte.Object);
            var sp = MockObjectFactory.CreateVsServiceProvider(
                Tuple.Create(typeof(SDTE), (object)(_dte.Object)),
                Tuple.Create(typeof(SVsShell), (object)(new Mock <IVsShell>(MockBehavior.Strict)).Object));

            _optionsDialogService   = new Mock <IOptionsDialogService>(MockBehavior.Strict);
            _vimApplicationSettings = new Mock <IVimApplicationSettings>(MockBehavior.Strict);
            _vimApplicationSettings.SetupGet(x => x.IgnoredConflictingKeyBinding).Returns(false);
            _vimApplicationSettings.SetupGet(x => x.HaveUpdatedKeyBindings).Returns(false);

            var list = new List <CommandKeyBinding>();

            _vimApplicationSettings.SetupGet(x => x.RemovedBindings).Returns(list.AsReadOnly());

            _serviceRaw = new KeyBindingService(
                sp.Object,
                _optionsDialogService.Object,
                new Mock <IProtectedOperations>().Object,
                _vimApplicationSettings.Object);
            _service = _serviceRaw;

            var result = _dte.Object.Commands.Count;
        }
Ejemplo n.º 3
0
        internal CommandKeyBindingSnapshot CreateCommandKeyBindingSnapshot(HashSet <KeyInput> vimFirstKeyInputSet)
        {
            var commandListSnapshot = new CommandListSnapshot(_dte);
            var conflicting         = FindConflictingCommandKeyBindings(commandListSnapshot, vimFirstKeyInputSet);
            var removed             = FindRemovedKeyBindings(commandListSnapshot);

            return(new CommandKeyBindingSnapshot(
                       commandListSnapshot,
                       vimFirstKeyInputSet,
                       removed,
                       conflicting));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Find all of the Command instances (which represent Visual Studio commands) which would conflict with any
        /// VsVim commands that use the keys in neededInputs.
        /// </summary>
        internal List <CommandKeyBinding> FindConflictingCommandKeyBindings(CommandListSnapshot commandsSnapshot, HashSet <KeyInput> neededInputs)
        {
            var list = new List <CommandKeyBinding>();
            var all  = commandsSnapshot.CommandKeyBindings.Where(x => !ShouldSkip(x));

            foreach (var binding in all)
            {
                var input = binding.KeyBinding.FirstKeyStroke.AggregateKeyInput;
                if (neededInputs.Contains(input))
                {
                    list.Add(binding);
                }
            }

            return(list);
        }
Ejemplo n.º 5
0
        protected virtual void Create(params EnvDTE.Command[] args)
        {
            _dte = MockObjectFactory.CreateDteWithCommands(args);
            _commandListSnapshot = new CommandListSnapshot(_dte.Object);
            _optionsDialogService = new Mock<IOptionsDialogService>(MockBehavior.Strict);
            _vimApplicationSettings = new Mock<IVimApplicationSettings>(MockBehavior.Strict);
            _vimApplicationSettings.SetupProperty(x => x.IgnoredConflictingKeyBinding, false);
            _vimApplicationSettings.SetupProperty(x => x.HaveUpdatedKeyBindings, false);
            _vimApplicationSettings.SetupProperty(x => x.KeyMappingIssueFixed, true);

            var list = new List<CommandKeyBinding>();
            _vimApplicationSettings.SetupGet(x => x.RemovedBindings).Returns(list.AsReadOnly());

            _serviceRaw = new KeyBindingService(
                _dte.Object,
                _optionsDialogService.Object,
                new Mock<IVimProtectedOperations>().Object,
                _vimApplicationSettings.Object,
                ScopeData.Default);
            _service = _serviceRaw;

            var result = _dte.Object.Commands.Count;
        }
Ejemplo n.º 6
0
        protected virtual void Create(params EnvDTE.Command[] args)
        {
            _dte = MockObjectFactory.CreateDteWithCommands(args);
            _commandListSnapshot     = new CommandListSnapshot(_dte.Object);
            _keyboardOptionsProvider = new Mock <IKeyboardOptionsProvider>(MockBehavior.Strict);
            _vimApplicationSettings  = new Mock <IVimApplicationSettings>(MockBehavior.Strict);
            _vimApplicationSettings.SetupProperty(x => x.IgnoredConflictingKeyBinding, false);
            _vimApplicationSettings.SetupProperty(x => x.HaveUpdatedKeyBindings, false);
            _vimApplicationSettings.SetupProperty(x => x.KeyMappingIssueFixed, true);

            var list = new List <CommandKeyBinding>();

            _vimApplicationSettings.SetupGet(x => x.RemovedBindings).Returns(list.AsReadOnly());

            _serviceRaw = new KeyBindingService(
                _dte.Object,
                _keyboardOptionsProvider.Object,
                new Mock <IVimProtectedOperations>().Object,
                _vimApplicationSettings.Object,
                ScopeData.Default);
            _service = _serviceRaw;

            var result = _dte.Object.Commands.Count;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Returns the list of commands that were previously removed by the user and are no longer currently active.
 /// </summary>
 internal List<CommandKeyBinding> FindRemovedKeyBindings(CommandListSnapshot commandListSnapshot)
 {
     return _vimApplicationSettings
         .RemovedBindings
         .Where(x => !commandListSnapshot.IsActive(x))
         .ToList();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Find all of the Command instances (which represent Visual Studio commands) which would conflict with any
        /// VsVim commands that use the keys in neededInputs.
        /// </summary>
        internal List<CommandKeyBinding> FindConflictingCommandKeyBindings(CommandListSnapshot commandsSnapshot, HashSet<KeyInput> neededInputs)
        {
            var list = new List<CommandKeyBinding>();
            var all = commandsSnapshot.CommandKeyBindings.Where(x => !ShouldSkip(x));
            foreach (var binding in all)
            {
                var input = binding.KeyBinding.FirstKeyStroke.AggregateKeyInput;
                if (neededInputs.Contains(input))
                {
                    list.Add(binding);
                }
            }

            return list;
        }
Ejemplo n.º 9
0
        internal CommandKeyBindingSnapshot CreateCommandKeyBindingSnapshot(HashSet<KeyInput> vimFirstKeyInputSet)
        {
            var commandListSnapshot = new CommandListSnapshot(_dte);
            var conflicting = FindConflictingCommandKeyBindings(commandListSnapshot, vimFirstKeyInputSet);
            var removed = FindRemovedKeyBindings(commandListSnapshot);

            return new CommandKeyBindingSnapshot(
                commandListSnapshot,
                vimFirstKeyInputSet,
                removed,
                conflicting);
        }
Ejemplo n.º 10
0
        private void Create(params string[] args)
        {
            _dte = MockObjectFactory.CreateDteWithCommands(args);
            _commandListSnapshot = new CommandListSnapshot(_dte.Object);
            var sp = MockObjectFactory.CreateVsServiceProvider(
                Tuple.Create(typeof(SDTE), (object)(_dte.Object)),
                Tuple.Create(typeof(SVsShell), (object)(new Mock<IVsShell>(MockBehavior.Strict)).Object));
            _optionsDialogService = new Mock<IOptionsDialogService>(MockBehavior.Strict);
            _vimApplicationSettings = new Mock<IVimApplicationSettings>(MockBehavior.Strict);
            _vimApplicationSettings.SetupGet(x => x.IgnoredConflictingKeyBinding).Returns(false);
            _vimApplicationSettings.SetupGet(x => x.HaveUpdatedKeyBindings).Returns(false);

            var list = new List<CommandKeyBinding>();
            _vimApplicationSettings.SetupGet(x => x.RemovedBindings).Returns(list.AsReadOnly());

            _serviceRaw = new KeyBindingService(
                sp.Object,
                _optionsDialogService.Object,
                new Mock<IProtectedOperations>().Object,
                _vimApplicationSettings.Object);
            _service = _serviceRaw;

            var result = _dte.Object.Commands.Count;
        }