From 9be3ff2b3f28efe0935d77d66522897a3be7a2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yago=20Gonz=C3=A1lez?= Date: Thu, 22 Jun 2017 23:40:45 +0200 Subject: [PATCH] composebox_typeahead: Remove unnecessary autocomplete_checks. The validations that autocomplete_checks did were already managed by tokenize_compose_str and the main "if" statements in compose_content_begins_typeahead. --- static/js/composebox_typeahead.js | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index a224b3ed08..dfe8cebd48 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -174,23 +174,6 @@ function select_on_focus(field_id) { }); } -function autocomplete_checks(q, char) { - // Don't autocomplete more than this many characters. - var max_chars = 30; - var last_at = q.lastIndexOf(char); - if (last_at === -1 || last_at < q.length - 1 - max_chars) { - return false; // char doesn't appear, or too far back - } - - // Only match if the char follows a space, various punctuation, - // or is at the beginning of the string. - if (last_at > 0 && "\n\t \"'(){}[]".indexOf(q[last_at - 1]) === -1) { - return false; - } - - return true; -} - exports.split_at_cursor = function (query, input) { var cursor = input.caret(); return [query.slice(0, cursor), query.slice(cursor)]; @@ -283,10 +266,6 @@ exports.compose_content_begins_typeahead = function (query) { } if (this.options.completions.mention && current_token[0] === '@') { - if (!autocomplete_checks(q, '@')) { - return false; - } - current_token = current_token.substring(1); if (current_token.length < 1 || current_token.lastIndexOf('*') !== -1) { return false; @@ -313,10 +292,6 @@ exports.compose_content_begins_typeahead = function (query) { } if (this.options.completions.stream && current_token[0] === '#') { - if (!autocomplete_checks(q, '#')) { - return false; - } - if (current_token.length === 1) { return false; }