diff --git a/ext/autocomplete/main.php b/ext/autocomplete/main.php index 25d779b1..abc7f09e 100644 --- a/ext/autocomplete/main.php +++ b/ext/autocomplete/main.php @@ -50,7 +50,10 @@ class AutoComplete extends Extension $limitSQL = ""; $search = str_replace('_', '\_', $search); $search = str_replace('%', '\%', $search); - $SQLarr = ["search" => "$search%"]; #, "cat_search"=>"%:$search%"]; + $SQLarr = [ + "search" => "$search%", + "cat_search" => Extension::is_enabled(TagCategoriesInfo::KEY) ? "%:$search%" : "", + ]; if ($limit !== 0) { $limitSQL = "LIMIT :limit"; $SQLarr['limit'] = $limit; @@ -62,7 +65,7 @@ class AutoComplete extends Extension SELECT tag, count FROM tags WHERE LOWER(tag) LIKE LOWER(:search) - -- OR LOWER(tag) LIKE LOWER(:cat_search) + OR LOWER(tag) LIKE LOWER(:cat_search) AND count > 0 ORDER BY count DESC, tag ASC $limitSQL diff --git a/ext/autocomplete/script.js b/ext/autocomplete/script.js index bdd9c1b4..7c59a4ea 100644 --- a/ext/autocomplete/script.js +++ b/ext/autocomplete/script.js @@ -95,7 +95,11 @@ function renderCompletions(element) { // add children for top completions, with the selected one highlighted let word = getCurrentWord(element); Object.keys(completions).filter( - (key) => key.toLowerCase().startsWith(word.toLowerCase()) + (key) => { + let k = key.toLowerCase(); + let w = word.toLowerCase(); + return k.split(':').some((k) => k.startsWith(w)) + } ).slice(0, 100).forEach((key, i) => { let value = completions[key]; let li = document.createElement('li');