mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Do not stop showing suggestions when entering double colon for separator
This commit is contained in:
parent
c9d3e5462e
commit
a6504e3f47
1 changed files with 17 additions and 8 deletions
|
@ -65,20 +65,29 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
return response.tags;
|
return response.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const colonAtStartOrEnd = /^:?|:?$/g;
|
||||||
|
|
||||||
function updateSuggestions(): void {
|
function updateSuggestions(): void {
|
||||||
const activeTag = tags[active!];
|
const activeTag = tags[active!];
|
||||||
const activeName = activeTag.name;
|
const activeName = activeTag.name;
|
||||||
|
|
||||||
autocompleteDisabled = activeName.length === 0;
|
autocompleteDisabled = activeName.length === 0;
|
||||||
suggestionsPromise = autocompleteDisabled
|
|
||||||
? noSuggestions
|
if (autocompleteDisabled) {
|
||||||
: fetchSuggestions(replaceWithColons(activeTag.name)).then(
|
suggestionsPromise = noSuggestions;
|
||||||
|
} else {
|
||||||
|
const cleanedName = replaceWithColons(activeName).replace(
|
||||||
|
colonAtStartOrEnd,
|
||||||
|
""
|
||||||
|
);
|
||||||
|
suggestionsPromise = fetchSuggestions(cleanedName).then(
|
||||||
(names: string[]): string[] => {
|
(names: string[]): string[] => {
|
||||||
autocompleteDisabled = names.length === 0;
|
autocompleteDisabled = names.length === 0;
|
||||||
return names.map(replaceWithUnicodeSeparator);
|
return names.map(replaceWithUnicodeSeparator);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onAutocomplete(selected: string): void {
|
function onAutocomplete(selected: string): void {
|
||||||
const activeTag = tags[active!];
|
const activeTag = tags[active!];
|
||||||
|
|
Loading…
Reference in a new issue