composebox_typeahead.js: Add typeahead cancelling for '# '.

If somebody types '# ', then close the typeahead dialog and
don't autocomplete. Relevant node tests were also added.

Fixes #4505.
This commit is contained in:
Cory Lynch 2017-04-20 00:28:18 -04:00 committed by Tim Abbott
parent 60225012e6
commit 0d9b77c8b7
2 changed files with 7 additions and 0 deletions

View File

@ -59,6 +59,8 @@ global.people.add({
assert_typeahead_equals("test @", false);
assert_typeahead_equals("test no@o", false);
assert_typeahead_equals("test :-P", false);
assert_typeahead_equals("test # a", false);
assert_typeahead_equals("test #", false);
var all_items = [
{

View File

@ -289,6 +289,11 @@ exports.compose_content_begins_typeahead = function (query) {
return false;
}
// Don't autocomplete if there is a space following a '#'
if (current_token[0] === " ") {
return false;
}
this.completing = 'stream';
this.token = current_token.substring(current_token.indexOf("#")+1);
return stream_data.subscribed_subs();