add a config option to show all result

This commit is contained in:
sgmklp
2022-10-16 19:02:33 +08:00
parent cb31b072b4
commit 046e2d99fb
2 changed files with 9 additions and 4 deletions

View File

@@ -424,14 +424,18 @@ function autocomplete(textArea, prompt, fixedTag = null) {
results = allTags.filter(x => x[2] && x[2].toLowerCase().includes(tagword)); // check have translation
// if search by [a~z],first list the translations, and then search English if it is not enough
// if only show translation,it is unnecessary to list English results
if (results.length < acConfig.maxResults && !acConfig.translation.onlyShowTranslation) {
allTags.filter(x => x[0].toLowerCase().includes(tagword) && !results.includes(x)).map(x => results.push(x));
if (!acConfig.translation.onlyShowTranslation) {
results = results.concat(allTags.filter(x => x[0].toLowerCase().includes(tagword) && !results.includes(x)));
}
results = results.slice(0, acConfig.maxResults);
} else {
results = allTags.filter(x => x[0].toLowerCase().includes(tagword)).slice(0, acConfig.maxResults);
results = allTags.filter(x => x[0].toLowerCase().includes(tagword));
}
// it's good to show all results
if (!acConfig.showAllResults) {
results = results.slice(0, acConfig.maxResults);
}
}
resultCount = results.length;
// Guard for empty results

View File

@@ -10,6 +10,7 @@
"escapeParentheses": true,
"useWildcards": true,
"useEmbeddings": true,
"showAllResults": false,
"translation": {
"searchByTranslation": true,
"onlyShowTranslation": false,