Skip to content

Commit d091742

Browse files
authored
Merge pull request #358 from zenonet/master
Allow customisation of the keys that trigger insertation of a completion
2 parents e9cb45e + 7102287 commit d091742

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/AvaloniaEdit/CodeCompletion/CompletionList.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public class CompletionList : TemplatedControl
3838
public CompletionList()
3939
{
4040
DoubleTapped += OnDoubleTapped;
41+
42+
CompletionAcceptKeys = new[]
43+
{
44+
Key.Enter,
45+
Key.Tab,
46+
};
4147
}
4248

4349

@@ -103,6 +109,11 @@ public CompletionListBox ListBox
103109
}
104110
}
105111

112+
/// <summary>
113+
/// Gets or sets the array of keys that are supposed to request insertation of the completion
114+
/// </summary>
115+
public Key[] CompletionAcceptKeys { get; set; }
116+
106117
/// <summary>
107118
/// Gets the scroll viewer used in this list box.
108119
/// </summary>
@@ -163,13 +174,13 @@ public void HandleKey(KeyEventArgs e)
163174
e.Handled = true;
164175
_listBox.SelectIndex(_listBox.ItemCount - 1);
165176
break;
166-
case Key.Tab:
167-
case Key.Enter:
168-
if(CurrentList.Count > 0)
177+
default:
178+
if (CompletionAcceptKeys.Contains(e.Key) && CurrentList.Count > 0)
169179
{
170180
e.Handled = true;
171181
RequestInsertion(e);
172-
}
182+
}
183+
173184
break;
174185
}
175186
}

0 commit comments

Comments
 (0)