From 55266be2ef1ce938ad3fa6145fbbeee229afcbe9 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 29 Aug 2022 14:06:39 -0500 Subject: [PATCH] autocomplete: drop support for shortcut abbreviations in aliases. Previously if you typed e.g. "/tr" in autocomplete we would first check if "/tr" was aliased to another tag before expanding out the abbreviation. This was for compatibility with legacy shortcut aliases. These aliases have been removed so this is dead code now. --- app/logical/autocomplete_service.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/logical/autocomplete_service.rb b/app/logical/autocomplete_service.rb index 1eada7160..a713f6e98 100644 --- a/app/logical/autocomplete_service.rb +++ b/app/logical/autocomplete_service.rb @@ -105,12 +105,9 @@ class AutocompleteService if !string.ascii_only? results = tag_other_name_matches(string) elsif string.starts_with?("/") - string = string + "*" unless string.include?("*") - - results = tag_matches(string) - results += tag_abbreviation_matches(string) + results = tag_abbreviation_matches(string) results = results.sort_by do |r| - [r[:type] == "tag-alias" ? 0 : 1, r[:antecedent].to_s.size, -r[:post_count]] + [r[:antecedent].to_s.size, -r[:post_count]] end results = results.uniq { |r| r[:value] }.take(limit) @@ -149,6 +146,7 @@ class AutocompleteService def tag_abbreviation_matches(string, max_length: 10) return [] if string.size > max_length + string += "*" unless string.include?("*") tags = Tag.nonempty.abbreviation_matches(string).order(post_count: :desc).limit(limit) tags.map do |tag|