From bec222f2b30fb1a55adeff55ee3737d94cf6f606 Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Thu, 12 Jan 2023 15:54:57 +0100 Subject: [PATCH] Fix for 1-letter completion Completion would sometimes not show if the prompt was only one letter long and identical to the previous completion --- javascript/tagAutocomplete.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index b7c866f..dd63fcd 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -576,6 +576,8 @@ async function autocomplete(textArea, prompt, fixedTag = null) { // Guard for empty prompt if (prompt.length === 0) { hideResults(textArea); + previousTags = []; + tagword = ""; return; } @@ -590,6 +592,14 @@ async function autocomplete(textArea, prompt, fixedTag = null) { .concat(weightedTags); } + // Guard for no tags + if (!tags || tags.length === 0) { + previousTags = []; + tagword = ""; + hideResults(textArea); + return; + } + let tagCountChange = tags.length - previousTags.length; let diff = difference(tags, previousTags); previousTags = tags;