diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte index 31307ddb7..6c0d3baab 100644 --- a/ts/editor/TagEditor.svelte +++ b/ts/editor/TagEditor.svelte @@ -65,7 +65,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html return response.tags; } - const colonAtStartOrEnd = /^:?|:?$/g; + const withoutSingleColonAtStartOrEnd = /^:?([^:].*?[^:]):?$/; function updateSuggestions(): void { const activeTag = tags[active!]; @@ -76,11 +76,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html if (autocompleteDisabled) { suggestionsPromise = noSuggestions; } else { - const cleanedName = replaceWithColons(activeName).replace( - colonAtStartOrEnd, - "" - ); - suggestionsPromise = fetchSuggestions(cleanedName).then( + const withColons = replaceWithColons(activeName); + const withoutSingleColons = withoutSingleColonAtStartOrEnd.test(withColons) + ? withColons.replace(withoutSingleColonAtStartOrEnd, "$1") + : withColons; + + suggestionsPromise = fetchSuggestions(withoutSingleColons).then( (names: string[]): string[] => { autocompleteDisabled = names.length === 0; return names.map(replaceWithUnicodeSeparator); diff --git a/ts/editor/TagInput.svelte b/ts/editor/TagInput.svelte index 941e2d4ee..d1e072d72 100644 --- a/ts/editor/TagInput.svelte +++ b/ts/editor/TagInput.svelte @@ -132,6 +132,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html await tick(); setPosition(positionStart); + dispatch("taginput"); return; } else if (after.startsWith(":")) { event.preventDefault();