Example #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(CommandsSnapshot commandsSnapshot)
 {
     return(_legacySettings
            .FindKeyBindingsMarkedAsRemoved(commandsSnapshot)
            .Where(x => !commandsSnapshot.IsKeyBindingActive(x.KeyBinding))
            .ToList());
 }
Example #2
0
        private static KeyBindingUtil Create(params string[] args)
        {
            var all      = MockObjectFactory.CreateCommandList(args).Select(x => x.Object);
            var snapshot = new CommandsSnapshot(all);

            return(new KeyBindingUtil(snapshot));
        }
Example #3
0
        private void Create(params string[] args)
        {
            _dte = MockObjectFactory.CreateDteWithCommands(args);
            _commandsSnapshot = new CommandsSnapshot(_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;
        }
Example #4
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(CommandsSnapshot commandsSnapshot)
 {
     return(_vimApplicationSettings
            .RemovedBindings
            .Where(x => !commandsSnapshot.IsKeyBindingActive(x.KeyBinding))
            .ToList());
 }
Example #5
0
        internal CommandKeyBindingSnapshot CreateCommandKeyBindingSnapshot(HashSet <KeyInput> needed)
        {
            var commandsSnapshot = new CommandsSnapshot(_dte);
            var conflicting      = FindConflictingCommandKeyBindings(commandsSnapshot, needed);
            var removed          = FindRemovedKeyBindings(commandsSnapshot);

            return(new CommandKeyBindingSnapshot(
                       commandsSnapshot,
                       removed,
                       conflicting));
        }
Example #6
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(CommandsSnapshot 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);
        }
Example #7
0
        private void Create(params string[] args)
        {
            _dte = MockObjectFactory.CreateDteWithCommands(args);
            _commandsSnapshot = new CommandsSnapshot(_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);
            _serviceRaw           = new KeyBindingService(
                sp.Object,
                _optionsDialogService.Object,
                new Mock <IProtectedOperations>().Object,
                new Mock <ILegacySettings>().Object);
            _service = _serviceRaw;
        }
Example #8
0
 private static KeyBindingUtil Create(params string[] args)
 {
     var all = MockObjectFactory.CreateCommandList(args).Select(x => x.Object);
     var snapshot = new CommandsSnapshot(all);
     return new KeyBindingUtil(snapshot, KeyBindingService.GetDefaultImportantScopeSet());
 }
        private void Create(params string[] args)
        {
            _dte = MockObjectFactory.CreateDteWithCommands(args);
            _commandsSnapshot = new CommandsSnapshot(_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);
            _legacySettings = new Mock<ILegacySettings>(MockBehavior.Strict);
            _legacySettings.SetupGet(x => x.IgnoredConflictingKeyBinding).Returns(false);
            _legacySettings.SetupGet(x => x.HaveUpdatedKeyBindings).Returns(false);
            _serviceRaw = new KeyBindingService(
                sp.Object,
                _optionsDialogService.Object,
                new Mock<IProtectedOperations>().Object,
                _legacySettings.Object);
            _service = _serviceRaw;

            var result = _dte.Object.Commands.Count;
        }
Example #10
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(CommandsSnapshot commandsSnapshot)
 {
     return _legacySettings.FindKeyBindingsMarkedAsRemoved().Where(x => !commandsSnapshot.IsKeyBindingActive(x.KeyBinding)).ToList();
 }
Example #11
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(CommandsSnapshot 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;
        }
Example #12
0
 internal CommandKeyBindingSnapshot CreateCommandKeyBindingSnapshot(HashSet<KeyInput> needed)
 {
     var commandsSnapshot = new CommandsSnapshot(_dte);
     var conflicting = FindConflictingCommandKeyBindings(commandsSnapshot, needed);
     var removed = FindRemovedKeyBindings(commandsSnapshot);
     return new CommandKeyBindingSnapshot(
         commandsSnapshot,
         removed,
         conflicting);
 }
Example #13
0
 private void Create(params string[] args)
 {
     _dte = MockObjectFactory.CreateDteWithCommands(args);
     _commandsSnapshot = new CommandsSnapshot(_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);
     _serviceRaw = new KeyBindingService(
         sp.Object,
         _optionsDialogService.Object,
         new Mock<IProtectedOperations>().Object,
         new Mock<ILegacySettings>().Object);
     _service = _serviceRaw;
 }
Example #14
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(CommandsSnapshot commandsSnapshot)
 {
     return _vimApplicationSettings
         .RemovedBindings
         .Where(x => !commandsSnapshot.IsKeyBindingActive(x.KeyBinding))
         .ToList();
 }
Example #15
0
 private static KeyBindingUtil Create(params string[] args)
 {
     var all = MockObjectFactory.CreateCommandList(args).Select(x => x.Object);
     var snapshot = new CommandsSnapshot(all);
     return new KeyBindingUtil(snapshot);
 }