From 61a97175a70b67c5f920a66b4e6645fcd3b12360 Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Tue, 1 Nov 2022 13:03:03 +0100 Subject: [PATCH] Fix parentheses regression Fixes #59 --- javascript/tagAutocomplete.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 32d1f71..9b16bea 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -289,7 +289,8 @@ function insertTextAtCursor(textArea, result, tagword) { textArea.dispatchEvent(new Event("input", { bubbles: true })); // Update previous tags with the edited prompt to prevent re-searching the same term - let weightedTags = newPrompt.match(WEIGHT_REGEX) + let weightedTags = [...newPrompt.matchAll(WEIGHT_REGEX)] + .map(match => match[1]); let tags = newPrompt.match(TAG_REGEX) if (weightedTags !== null) { tags = tags.filter(tag => !weightedTags.some(weighted => tag.includes(weighted))) @@ -402,7 +403,8 @@ async function autocomplete(textArea, prompt, fixedTag = null) { if (fixedTag === null) { // Match tags with RegEx to get the last edited one // We also match for the weighting format (e.g. "tag:1.0") here, and combine the two to get the full tag word set - let weightedTags = prompt.match(WEIGHT_REGEX) + let weightedTags = [...prompt.matchAll(WEIGHT_REGEX)] + .map(match => match[1]); let tags = prompt.match(TAG_REGEX) if (weightedTags !== null) { tags = tags.filter(tag => !weightedTags.some(weighted => tag.includes(weighted)))