Do not stop showing suggestions when entering double colon for separator

This commit is contained in:
Henrik Giesel 2021-09-15 02:02:19 +02:00
parent c9d3e5462e
commit a6504e3f47

View file

@ -65,19 +65,28 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
return response.tags;
}
const colonAtStartOrEnd = /^:?|:?$/g;
function updateSuggestions(): void {
const activeTag = tags[active!];
const activeName = activeTag.name;
autocompleteDisabled = activeName.length === 0;
suggestionsPromise = autocompleteDisabled
? noSuggestions
: fetchSuggestions(replaceWithColons(activeTag.name)).then(
(names: string[]): string[] => {
autocompleteDisabled = names.length === 0;
return names.map(replaceWithUnicodeSeparator);
}
);
if (autocompleteDisabled) {
suggestionsPromise = noSuggestions;
} else {
const cleanedName = replaceWithColons(activeName).replace(
colonAtStartOrEnd,
""
);
suggestionsPromise = fetchSuggestions(cleanedName).then(
(names: string[]): string[] => {
autocompleteDisabled = names.length === 0;
return names.map(replaceWithUnicodeSeparator);
}
);
}
}
function onAutocomplete(selected: string): void {