@@ -68,7 +68,7 @@ void main() {
6868 ///
6969 /// For example, "~@chris^" means the text is "@chris", the selection is
7070 /// collapsed at index 6, and we expect the syntax to start at index 0.
71- void doTest (String markedText, MentionAutocompleteQuery ? expectedQuery) {
71+ void doTest (String markedText, ComposeAutocompleteQuery ? expectedQuery) {
7272 final description = expectedQuery != null
7373 ? 'in ${jsonEncode (markedText )}, query ${jsonEncode (expectedQuery .raw )}'
7474 : 'no query in ${jsonEncode (markedText )}' ;
@@ -87,8 +87,8 @@ void main() {
8787 });
8888 }
8989
90- MentionAutocompleteQuery queryOf (String raw) => MentionAutocompleteQuery (raw, silent: false );
91- MentionAutocompleteQuery silentQueryOf (String raw) => MentionAutocompleteQuery (raw, silent: true );
90+ MentionAutocompleteQuery mention (String raw) => MentionAutocompleteQuery (raw, silent: false );
91+ MentionAutocompleteQuery silentMention (String raw) => MentionAutocompleteQuery (raw, silent: true );
9292
9393 doTest ('' , null );
9494 doTest ('^' , null );
@@ -125,48 +125,48 @@ void main() {
125125
126126 doTest ('`@chris^' , null ); doTest ('`@_chris^' , null );
127127
128- doTest ('~@^_' , queryOf ('' )); // Odd/unlikely, but should not crash
128+ doTest ('~@^_' , mention ('' )); // Odd/unlikely, but should not crash
129129
130- doTest ('~@__^' , silentQueryOf ('_' ));
130+ doTest ('~@__^' , silentMention ('_' ));
131131
132- doTest ('~@^abc^' , queryOf ('abc' )); doTest ('~@_^abc^' , silentQueryOf ('abc' ));
133- doTest ('~@a^bc^' , queryOf ('abc' )); doTest ('~@_a^bc^' , silentQueryOf ('abc' ));
134- doTest ('~@ab^c^' , queryOf ('abc' )); doTest ('~@_ab^c^' , silentQueryOf ('abc' ));
135- doTest ('~^@^' , queryOf ('' )); doTest ('~^@_^' , silentQueryOf ('' ));
132+ doTest ('~@^abc^' , mention ('abc' )); doTest ('~@_^abc^' , silentMention ('abc' ));
133+ doTest ('~@a^bc^' , mention ('abc' )); doTest ('~@_a^bc^' , silentMention ('abc' ));
134+ doTest ('~@ab^c^' , mention ('abc' )); doTest ('~@_ab^c^' , silentMention ('abc' ));
135+ doTest ('~^@^' , mention ('' )); doTest ('~^@_^' , silentMention ('' ));
136136 // but:
137137 doTest ('^hello @chris^' , null ); doTest ('^hello @_chris^' , null );
138138
139- 140- doTest (
'~@me@^zulip.com^' ,
queryOf (
'[email protected] ' ));
doTest (
'~@_me@^zulip.com^' ,
silentQueryOf (
'[email protected] ' ));
141- doTest (
'~@me^@zulip.com^' ,
queryOf (
'[email protected] ' ));
doTest (
'~@_me^@zulip.com^' ,
silentQueryOf (
'[email protected] ' ));
142- 143-
144- doTest ('~@abc^' , queryOf ('abc' )); doTest ('~@_abc^' , silentQueryOf ('abc' ));
145- doTest (' ~@abc^' , queryOf ('abc' )); doTest (' ~@_abc^' , silentQueryOf ('abc' ));
146- doTest ('(~@abc^' , queryOf ('abc' )); doTest ('(~@_abc^' , silentQueryOf ('abc' ));
147- doTest ('—~@abc^' , queryOf ('abc' )); doTest ('—~@_abc^' , silentQueryOf ('abc' ));
148- doTest ('"~@abc^' , queryOf ('abc' )); doTest ('"~@_abc^' , silentQueryOf ('abc' ));
149- doTest ('“~@abc^' , queryOf ('abc' )); doTest ('“~@_abc^' , silentQueryOf ('abc' ));
150- doTest ('。~@abc^' , queryOf ('abc' )); doTest ('。~@_abc^' , silentQueryOf ('abc' ));
151- doTest ('«~@abc^' , queryOf ('abc' )); doTest ('«~@_abc^' , silentQueryOf ('abc' ));
152-
153- doTest ('~@ab^c' , queryOf ('ab' )); doTest ('~@_ab^c' , silentQueryOf ('ab' ));
154- doTest ('~@a^bc' , queryOf ('a' )); doTest ('~@_a^bc' , silentQueryOf ('a' ));
155- doTest ('~@^abc' , queryOf ('' )); doTest ('~@_^abc' , silentQueryOf ('' ));
156- doTest ('~@^' , queryOf ('' )); doTest ('~@_^' , silentQueryOf ('' ));
157-
158- doTest ('~@abc ^' , queryOf ('abc ' )); doTest ('~@_abc ^' , silentQueryOf ('abc ' ));
159- doTest ('~@abc^ ^' , queryOf ('abc ' )); doTest ('~@_abc^ ^' , silentQueryOf ('abc ' ));
160- doTest ('~@ab^c ^' , queryOf ('abc ' )); doTest ('~@_ab^c ^' , silentQueryOf ('abc ' ));
161- doTest ('~@^abc ^' , queryOf ('abc ' )); doTest ('~@_^abc ^' , silentQueryOf ('abc ' ));
162-
163- doTest ('Please ask ~@chris^' , queryOf ('chris' )); doTest ('Please ask ~@_chris^' , silentQueryOf ('chris' ));
164- doTest ('Please ask ~@chris bobbe^' , queryOf ('chris bobbe' )); doTest ('Please ask ~@_chris bobbe^' , silentQueryOf ('chris bobbe' ));
165-
166- doTest ('~@Rodion Romanovich Raskolnikov^' , queryOf ('Rodion Romanovich Raskolnikov' ));
167- doTest ('~@_Rodion Romanovich Raskolniko^' , silentQueryOf ('Rodion Romanovich Raskolniko' ));
168- doTest ('~@Родион Романович Раскольников^' , queryOf ('Родион Романович Раскольников' ));
169- doTest ('~@_Родион Романович Раскольнико^' , silentQueryOf ('Родион Романович Раскольнико' ));
139+ 140+ doTest (
'~@me@^zulip.com^' ,
mention (
'[email protected] ' ));
doTest (
'~@_me@^zulip.com^' ,
silentMention (
'[email protected] ' ));
141+ doTest (
'~@me^@zulip.com^' ,
mention (
'[email protected] ' ));
doTest (
'~@_me^@zulip.com^' ,
silentMention (
'[email protected] ' ));
142+ 143+
144+ doTest ('~@abc^' , mention ('abc' )); doTest ('~@_abc^' , silentMention ('abc' ));
145+ doTest (' ~@abc^' , mention ('abc' )); doTest (' ~@_abc^' , silentMention ('abc' ));
146+ doTest ('(~@abc^' , mention ('abc' )); doTest ('(~@_abc^' , silentMention ('abc' ));
147+ doTest ('—~@abc^' , mention ('abc' )); doTest ('—~@_abc^' , silentMention ('abc' ));
148+ doTest ('"~@abc^' , mention ('abc' )); doTest ('"~@_abc^' , silentMention ('abc' ));
149+ doTest ('“~@abc^' , mention ('abc' )); doTest ('“~@_abc^' , silentMention ('abc' ));
150+ doTest ('。~@abc^' , mention ('abc' )); doTest ('。~@_abc^' , silentMention ('abc' ));
151+ doTest ('«~@abc^' , mention ('abc' )); doTest ('«~@_abc^' , silentMention ('abc' ));
152+
153+ doTest ('~@ab^c' , mention ('ab' )); doTest ('~@_ab^c' , silentMention ('ab' ));
154+ doTest ('~@a^bc' , mention ('a' )); doTest ('~@_a^bc' , silentMention ('a' ));
155+ doTest ('~@^abc' , mention ('' )); doTest ('~@_^abc' , silentMention ('' ));
156+ doTest ('~@^' , mention ('' )); doTest ('~@_^' , silentMention ('' ));
157+
158+ doTest ('~@abc ^' , mention ('abc ' )); doTest ('~@_abc ^' , silentMention ('abc ' ));
159+ doTest ('~@abc^ ^' , mention ('abc ' )); doTest ('~@_abc^ ^' , silentMention ('abc ' ));
160+ doTest ('~@ab^c ^' , mention ('abc ' )); doTest ('~@_ab^c ^' , silentMention ('abc ' ));
161+ doTest ('~@^abc ^' , mention ('abc ' )); doTest ('~@_^abc ^' , silentMention ('abc ' ));
162+
163+ doTest ('Please ask ~@chris^' , mention ('chris' )); doTest ('Please ask ~@_chris^' , silentMention ('chris' ));
164+ doTest ('Please ask ~@chris bobbe^' , mention ('chris bobbe' )); doTest ('Please ask ~@_chris bobbe^' , silentMention ('chris bobbe' ));
165+
166+ doTest ('~@Rodion Romanovich Raskolnikov^' , mention ('Rodion Romanovich Raskolnikov' ));
167+ doTest ('~@_Rodion Romanovich Raskolniko^' , silentMention ('Rodion Romanovich Raskolniko' ));
168+ doTest ('~@Родион Романович Раскольников^' , mention ('Родион Романович Раскольников' ));
169+ doTest ('~@_Родион Романович Раскольнико^' , silentMention ('Родион Романович Раскольнико' ));
170170 doTest ('If @chris is around, please ask him.^' , null ); // @ sign is too far away from cursor
171171 doTest ('If @_chris is around, please ask him.^' , null ); // @ sign is too far away from cursor
172172 });
0 commit comments