@@ -96,16 +96,22 @@ def stream_box_view(self, caption: str='', title: str='') -> None:
96
96
self .contents = write_box
97
97
98
98
def generic_autocomplete (self , text : str , state : int ) -> Optional [str ]:
99
+ autocomplete_forms = {
100
+ 'emojis' : self .autocomplete_emojis ,
101
+ 'mentions' : self .autocomplete_mentions ,
102
+ 'streams' : self .autocomplete_streams ,
103
+ }
99
104
if text .startswith ('@_' ):
100
- typeahead = self . autocomplete_mentions ( text , '@_' )
105
+ form , prefix_string = 'mentions' , '@_'
101
106
elif text .startswith ('@' ):
102
- typeahead = self . autocomplete_mentions ( text , '@' )
107
+ form , prefix_string = 'mentions' , '@'
103
108
elif text .startswith ('#' ):
104
- typeahead = self . autocomplete_streams ( text , '#' )
109
+ form , prefix_string = 'streams' , '#'
105
110
elif text .startswith (':' ):
106
- typeahead = self . autocomplete_emojis ( text , ':' )
111
+ form , prefix_string = 'emojis' , ':'
107
112
else :
108
113
return text
114
+ typeahead = autocomplete_forms [form ](text , prefix_string )
109
115
110
116
try :
111
117
return typeahead [state ]
0 commit comments