Fix diff check for negative tag count changes

Now properly closes the popup if the last letter of a tag gets deleted.
This commit is contained in:
Dominik Reh
2022-10-30 16:10:55 +01:00
parent e49862d422
commit 6c6999d5f1

View File

@@ -407,10 +407,13 @@ async function autocomplete(textArea, prompt, fixedTag = null) {
tags = tags.filter(tag => !weightedTags.some(weighted => tag.includes(weighted)))
.concat(weightedTags);
}
let tagCountChange = tags.length - previousTags.length;
let diff = difference(tags, previousTags);
previousTags = tags;
// Guard for no difference / only whitespace remaining
if (diff === null || diff.length === 0) {
// Guard for no difference / only whitespace remaining / last edited tag was fully removed
if (diff === null || diff.length === 0 || (diff.length === 1 && tagCountChange < 0)) {
if (!hideBlocked) hideResults(textArea);
return;
}