autocomplete: fix completion of ai: metatag.

Fix it so we don't show the `ai:` prefix in front of results in the
autocomplete menu when completing the `ai: metatag.
This commit is contained in:
evazion
2022-09-03 20:26:00 -05:00
parent f83af31a00
commit 4a77d67d1f
2 changed files with 8 additions and 6 deletions

View File

@@ -32,16 +32,18 @@ class AutocompleteComponent < ApplicationComponent
end
def highlight_result(result)
if result.type == "tag-word"
highlight_matching_words(result.value, query)
elsif result.type == "mention"
highlight_wildcard_match(result.label, query + "*")
elsif metatag.present? && metatag.value.include?("*")
if metatag.present? && metatag.value.include?("*")
highlight_wildcard_match(result.label, metatag.value)
elsif metatag.present? && metatag.name.in?(%w[pool favgroup])
highlight_wildcard_match(result.label, "*" + metatag.value + "*")
elsif metatag.present? && metatag.name.in?(%w[ai unaliased])
highlight_matching_words(result.label, metatag.value)
elsif metatag.present?
highlight_wildcard_match(result.label, metatag.value + "*")
elsif result.type == "tag-word"
highlight_matching_words(result.value, query)
elsif result.type == "mention"
highlight_wildcard_match(result.label, query + "*")
elsif query.include?("*")
highlight_wildcard_match(result.value, query)
else

View File

@@ -256,7 +256,7 @@ class Tag < ApplicationRecord
def split_words(name)
return [name] if !parsable_into_words?(name)
name.split(WORD_DELIMITER_REGEX).compact_blank
name.split(WORD_DELIMITER_REGEX).reject(&:empty?)
end
# Parse the tag into plain words, removing punctuation and delimiters.