diff --git a/Terminal.Gui/Text/CollectionNavigator.cs b/Terminal.Gui/Text/CollectionNavigator.cs index e0dc7d44e..18eb9bb01 100644 --- a/Terminal.Gui/Text/CollectionNavigator.cs +++ b/Terminal.Gui/Text/CollectionNavigator.cs @@ -212,14 +212,14 @@ namespace Terminal.Gui { /// /// Returns true if is a searchable key - /// (e.g. letters, numbers etc) that is valid to pass to to this + /// (e.g. letters, numbers, etc) that are valid to pass to this /// class for search filtering. /// /// /// public static bool IsCompatibleKey (KeyEvent kb) { - return !kb.IsAlt && !kb.IsCapslock && !kb.IsCtrl && !kb.IsScrolllock && !kb.IsNumlock; + return !kb.IsAlt && !kb.IsCtrl; } } } diff --git a/UnitTests/Text/CollectionNavigatorTests.cs b/UnitTests/Text/CollectionNavigatorTests.cs index 8ae522ca8..9031b157a 100644 --- a/UnitTests/Text/CollectionNavigatorTests.cs +++ b/UnitTests/Text/CollectionNavigatorTests.cs @@ -376,5 +376,33 @@ namespace Terminal.Gui.TextTests { Assert.Equal (-1, current = n.GetNextMatchingItem (current, "x", true)); } + + [Fact] + public void IsCompatibleKey_Does_Not_Allow_Alt_And_Ctrl_Keys () + { + // test all Keys + foreach (Key key in Enum.GetValues (typeof (Key))) { + var ke = new KeyEvent (key, new KeyModifiers () { + Alt = key == Key.AltMask, + Ctrl = key == Key.CtrlMask, + Shift = key == Key.ShiftMask + }); + if (key == Key.AltMask || key == Key.CtrlMask) { + Assert.False (CollectionNavigator.IsCompatibleKey (ke)); + } else { + Assert.True (CollectionNavigator.IsCompatibleKey (ke)); + } + } + + // test Capslock, Numlock and Scrolllock + Assert.True (CollectionNavigator.IsCompatibleKey (new KeyEvent (Key.Null, new KeyModifiers () { + Alt = false, + Ctrl = false, + Shift = false, + Capslock = true, + Numlock = true, + Scrolllock = true, + }))); + } } }