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)); }
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); } } }