From c348b907e759e356a63252f59f6a705ac46b959a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20Gonz=C3=A1lez?= Date: Thu, 22 Jun 2017 23:40:44 +0200 Subject: [PATCH] composebox_typeahead: Optimize token identification. --- static/js/composebox_typeahead.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index 361428df86..a224b3ed08 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -287,13 +287,13 @@ exports.compose_content_begins_typeahead = function (query) { return false; } - current_token = q.substring(q.lastIndexOf('@') + 1); + current_token = current_token.substring(1); if (current_token.length < 1 || current_token.lastIndexOf('*') !== -1) { return false; } this.completing = 'mention'; - this.token = current_token.substring(current_token.indexOf("@") + 1); + this.token = current_token; var all_item = { special_item_text: "all (Notify everyone)", email: "all", @@ -317,18 +317,19 @@ exports.compose_content_begins_typeahead = function (query) { return false; } - current_token = q.substring(q.lastIndexOf('#') + 1); - if (current_token.length < 1) { + if (current_token.length === 1) { return false; } + current_token = current_token.substring(1); + // 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); + this.token = current_token; return stream_data.subscribed_subs(); } return false;