diff --git a/src/AvaloniaEdit/CodeCompletion/CompletionList.cs b/src/AvaloniaEdit/CodeCompletion/CompletionList.cs index 53ba1e4d..e45e4cc1 100644 --- a/src/AvaloniaEdit/CodeCompletion/CompletionList.cs +++ b/src/AvaloniaEdit/CodeCompletion/CompletionList.cs @@ -38,6 +38,12 @@ public class CompletionList : TemplatedControl public CompletionList() { DoubleTapped += OnDoubleTapped; + + CompletionAcceptKeys = new[] + { + Key.Enter, + Key.Tab, + }; } @@ -103,6 +109,11 @@ public CompletionListBox ListBox } } + /// + /// Gets or sets the array of keys that are supposed to request insertation of the completion + /// + public Key[] CompletionAcceptKeys { get; set; } + /// /// Gets the scroll viewer used in this list box. /// @@ -163,13 +174,13 @@ public void HandleKey(KeyEventArgs e) e.Handled = true; _listBox.SelectIndex(_listBox.ItemCount - 1); break; - case Key.Tab: - case Key.Enter: - if(CurrentList.Count > 0) + default: + if (CompletionAcceptKeys.Contains(e.Key) && CurrentList.Count > 0) { e.Handled = true; RequestInsertion(e); - } + } + break; } }