File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
src/AvaloniaEdit/CodeCompletion Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments