private void ComputeKeyBindings() { // This snapshot contains a list of active keys, and keys which are still conflicting. We will group all // bindings by the initial character, and will consider the entire group as being handled by VsVim as long // as one is being handled. _snapshot = GetCommandKeyBindingSnapshot(); _keyBindingList.Clear(); _advancedSet.Clear(); var handledByVsVim = _snapshot.Removed.ToLookup(binding => binding.KeyBinding.FirstKeyStroke); var handledByVs = _snapshot.Conflicting.ToLookup(binding => binding.KeyBinding.FirstKeyStroke); var allFirstKeys = handledByVsVim.Select(group => group.Key) .Union(handledByVs.Select(group => group.Key)); foreach (var firstKey in allFirstKeys) { var data = new KeyBindingData(handledByVsVim[firstKey].Union(handledByVs[firstKey]).ToReadOnlyCollection()); data.HandledByVsVim = handledByVsVim.Contains(firstKey); _keyBindingList.Add(data); if (IsAdvanced(firstKey)) { _advancedSet.Add(data); } } }
public ConflictingKeyBindingDialog(CommandKeyBindingSnapshot snapshot) { InitializeComponent(); _snapshot = snapshot; ComputeKeyBindings(); BindingsListBox.ItemsSource = _keyBindingList; BindingsListBox.Items.SortDescriptions.Add(new SortDescription("KeyName", ListSortDirection.Ascending)); }
public ConflictingKeyBindingDialog(CommandKeyBindingSnapshot snapshot) { InitializeComponent(); _snapshot = snapshot; ComputeKeyBindings(); BindingsListBox.ItemsSource = _keyBindingList; BindingsListBox.Items.SortDescriptions.Add(new SortDescription("KeyName", ListSortDirection.Ascending)); }
public ConflictingKeyBindingDialog(CommandKeyBindingSnapshot snapshot, IVimApplicationSettings vimApplicationSettings, IProtectedOperations protectedOperations) { InitializeComponent(); _snapshot = snapshot; _vimApplicationSettings = vimApplicationSettings; _protectedOperations = protectedOperations; ComputeKeyBindings(); BindingsListBox.ItemsSource = _keyBindingList; BindingsListBox.Items.SortDescriptions.Add(new SortDescription("KeyName", ListSortDirection.Ascending)); }
public KeyboardSettingsControl(CommandKeyBindingSnapshot snapshot, IVimApplicationSettings vimApplicationSettings, IProtectedOperations protectedOperations) { InitializeComponent(); _snapshot = snapshot; _vimApplicationSettings = vimApplicationSettings; _protectedOperations = protectedOperations; ComputeKeyBindings(); BindingsListBox.ItemsSource = _keyBindingList; BindingsListBox.Items.SortDescriptions.Add(new SortDescription("KeyName", ListSortDirection.Ascending)); }
public void ResolveAnyConflicts4() { Create("::ctrl+h"); var snapshot = new CommandKeyBindingSnapshot( new CommandsSnapshot(_dte.Object), Enumerable.Empty <CommandKeyBinding>(), Enumerable.Empty <CommandKeyBinding>()); _serviceRaw.UpdateConflictingState(ConflictingKeyBindingState.FoundConflicts, snapshot); _optionsDialogService.Setup(x => x.ShowConflictingKeyBindingsDialog(snapshot)).Returns(false).Verifiable(); _serviceRaw.ResolveAnyConflicts(); Assert.AreEqual(ConflictingKeyBindingState.FoundConflicts, _service.ConflictingKeyBindingState); }
internal void ResolveAnyConflicts() { if (_snapshot == null || _state != ConflictingKeyBindingState.FoundConflicts) { return; } if (_optionsDialogService.ShowConflictingKeyBindingsDialog(_snapshot)) { ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved; _snapshot = null; } }
internal void RunConflictingKeyBindingStateCheck(IVimBuffer buffer) { // Create the set of KeyInput values which are handled by VsVim var needed = buffer.AllModes.Select(x => x.CommandNames).SelectMany(x => x).ToList(); needed.Add(KeyInputSet.NewOneKeyInput(buffer.LocalSettings.GlobalSettings.DisableAllCommand)); var set = new HashSet <KeyInput>(needed.Select(x => x.KeyInputs.First())); // Take a snapshot based on the current state of the DTE commands and store it // and the conflicting state _snapshot = CreateCommandKeyBindingSnapshot(set); ConflictingKeyBindingState = _snapshot.Conflicting.Any() ? ConflictingKeyBindingState.FoundConflicts : ConflictingKeyBindingState.ConflictsIgnoredOrResolved; }
public void RunConflictingKeyBindingStateCheck(IEnumerable <KeyInput> neededInputs, Action <ConflictingKeyBindingState, CommandKeyBindingSnapshot> onComplete) { if (_snapshot != null) { onComplete(_state, _snapshot); return; } var util = new KeyBindingUtil(_dte); var set = new HashSet <KeyInput>(neededInputs); _snapshot = util.CreateCommandKeyBindingSnapshot(set); ConflictingKeyBindingState = _snapshot.Conflicting.Any() ? ConflictingKeyBindingState.FoundConflicts : ConflictingKeyBindingState.ConflictsIgnoredOrResolved; }
public static bool DoShow(CommandKeyBindingSnapshot snapshot) { var window = new ConflictingKeyBindingDialog(); var removed = window.ConflictingKeyBindingControl.RemovedKeyBindingData; removed.AddRange(snapshot.Removed.Select(x => new KeyBindingData(x))); var current = window.ConflictingKeyBindingControl.ConflictingKeyBindingData; current.AddRange(snapshot.Conflicting.Select(x => new KeyBindingData(x))); var ret = window.ShowModal(); if (ret.HasValue && ret.Value) { // Remove all of the removed bindings foreach (var cur in removed) { var tuple = snapshot.TryGetCommand(cur.Name); if ( tuple.Item1 ) { tuple.Item2.SafeResetBindings(); } } // Restore all of the conflicting ones foreach (var cur in current) { KeyBinding binding; var tuple = snapshot.TryGetCommand(cur.Name); if ( tuple.Item1 && KeyBinding.TryParse(cur.Keys, out binding)) { tuple.Item2.SafeSetBindings(binding); } } var settings = Settings.Settings.Default; settings.RemovedBindings = removed .Select(x => new Settings.CommandBindingSetting() { Name = x.Name, CommandString = x.Keys }) .ToArray(); settings.HaveUpdatedKeyBindings = true; settings.Save(); } return ret.HasValue && ret.Value; }
internal void ResetConflictingKeyBindingState() { ConflictingKeyBindingState = ConflictingKeyBindingState.HasNotChecked; _snapshot = null; }
internal void IgnoreAnyConflicts() { ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved; _snapshot = null; }
public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot) { return(new ConflictingKeyBindingDialog(snapshot, _vimApplicationSettings).ShowDialog().Value); }
internal void ResetConflictingKeyBindingState() { ConflictingKeyBindingState = ConflictingKeyBindingState.HasNotChecked; _snapshot = null; }
internal void IgnoreAnyConflicts() { ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved; _snapshot = null; }
internal void UpdateConflictingState(ConflictingKeyBindingState state, CommandKeyBindingSnapshot snapshot) { _snapshot = snapshot; ConflictingKeyBindingState = state; }
public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot) { return(new UI.ConflictingKeyBindingDialog(snapshot, _legacySettings).ShowDialog().Value); }
public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot) { return new UI.ConflictingKeyBindingDialog(snapshot).ShowDialog().Value; }
internal void RunConflictingKeyBindingStateCheck(IVimBuffer buffer) { // Create the set of KeyInput values which are handled by VsVim var needed = buffer.AllModes.Select(x => x.CommandNames).SelectMany(x => x).ToList(); needed.Add(KeyInputSet.NewOneKeyInput(buffer.LocalSettings.GlobalSettings.DisableAllCommand)); var set = new HashSet<KeyInput>(needed.Select(x => x.KeyInputs.First())); // Take a snapshot based on the current state of the DTE commands and store it // and the conflicting state _snapshot = CreateCommandKeyBindingSnapshot(set); ConflictingKeyBindingState = _snapshot.Conflicting.Any() ? ConflictingKeyBindingState.FoundConflicts : ConflictingKeyBindingState.ConflictsIgnoredOrResolved; }
public void RunConflictingKeyBindingStateCheck(IEnumerable<KeyInput> neededInputs, Action<ConflictingKeyBindingState, CommandKeyBindingSnapshot> onComplete) { if (_snapshot != null) { onComplete(_state, _snapshot); return; } var util = new KeyBindingUtil(_dte); var set = new HashSet<KeyInput>(neededInputs); _snapshot = util.CreateCommandKeyBindingSnapshot(set); if (_snapshot.Conflicting.Any()) { ConflictingKeyBindingState = ConflictingKeyBindingState.FoundConflicts; } else { ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved; } }
internal void ResolveAnyConflicts() { if (_snapshot == null || _state != ConflictingKeyBindingState.FoundConflicts) { return; } if (_optionsDialogService.ShowConflictingKeyBindingsDialog(_snapshot)) { ConflictingKeyBindingState = ConflictingKeyBindingState.ConflictsIgnoredOrResolved; _snapshot = null; } }
public void ResolveAnyConflicts4() { Create("::ctrl+h"); var snapshot = new CommandKeyBindingSnapshot( new CommandsSnapshot(_dte.Object), Enumerable.Empty<CommandKeyBinding>(), Enumerable.Empty<CommandKeyBinding>()); _serviceRaw.UpdateConflictingState(ConflictingKeyBindingState.FoundConflicts, snapshot); _optionsDialogService.Setup(x => x.ShowConflictingKeyBindingsDialog(snapshot)).Returns(false).Verifiable(); _serviceRaw.ResolveAnyConflicts(); Assert.Equal(ConflictingKeyBindingState.FoundConflicts, _service.ConflictingKeyBindingState); }
internal void RunConflictingKeyBindingStateCheck(IEnumerable<KeyInput> neededInputs, Action<ConflictingKeyBindingState, CommandKeyBindingSnapshot> onComplete) { if (_snapshot != null) { onComplete(_state, _snapshot); return; } var util = new KeyBindingUtil(_dte, GetOrCreateImportantScopeSet()); var set = new HashSet<KeyInput>(neededInputs); _snapshot = util.CreateCommandKeyBindingSnapshot(set); ConflictingKeyBindingState = _snapshot.Conflicting.Any() ? ConflictingKeyBindingState.FoundConflicts : ConflictingKeyBindingState.ConflictsIgnoredOrResolved; }
internal void UpdateConflictingState(ConflictingKeyBindingState state, CommandKeyBindingSnapshot snapshot) { _snapshot = snapshot; ConflictingKeyBindingState = state; }
public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot) { return new ConflictingKeyBindingDialog(snapshot, _legacySettings).ShowDialog().Value; }
public bool ShowConflictingKeyBindingsDialog(CommandKeyBindingSnapshot snapshot) { return new ConflictingKeyBindingDialog(snapshot, _vimApplicationSettings, _protectedOperations).ShowDialog().Value; }