@@ -396,6 +396,11 @@ public class Settings : AutoConfiguration
|
||||
|
||||
[ConfigComment("Optional suffix to append to autocompletes, eg ', ' to append commas.")]
|
||||
public string Suffix = "";
|
||||
|
||||
[ConfigComment("How to match and list results.\n'Contains' lists any match that contains your current text\n'StartsWith' only lists matches that start with your current text\n'Bucketed' shows StartsWith matches first, and Contains matches after.")]
|
||||
[ManualSettingsOptions(Impl = null, Vals = ["Bucketed", "Contains", "StartsWith"])]
|
||||
public string MatchMode = "Bucketed";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1275,6 +1275,7 @@ class PromptTabCompleteClass {
|
||||
}
|
||||
let wordLow = word.toLowerCase();
|
||||
let rawMatchSet = [];
|
||||
let matchMode = getUserSetting('autocomplete.matchmode');
|
||||
if (completionSet) {
|
||||
let startWithList = [];
|
||||
let containList = [];
|
||||
@@ -1290,9 +1291,22 @@ class PromptTabCompleteClass {
|
||||
rawMatchSet.push(entry);
|
||||
}
|
||||
}
|
||||
startWithList.sort((a, b) => a.low.length - b.low.length || a.low.localeCompare(b.low));
|
||||
containList.sort((a, b) => a.low.length - b.low.length || a.low.localeCompare(b.low));
|
||||
baseList = startWithList.concat(containList);
|
||||
let doSortList = (list) => {
|
||||
return list.sort((a, b) => a.low.length - b.low.length || a.low.localeCompare(b.low));
|
||||
}
|
||||
if (matchMode == 'Bucketed') {
|
||||
doSortList(startWithList);
|
||||
doSortList(containList);
|
||||
baseList = startWithList.concat(containList);
|
||||
}
|
||||
else if (matchMode == 'Contains') {
|
||||
doSortList(rawMatchSet);
|
||||
baseList = rawMatchSet;
|
||||
}
|
||||
else if (matchMode == 'StartsWith') {
|
||||
doSortList(startWithList);
|
||||
baseList = startWithList;
|
||||
}
|
||||
if (baseList.length > 50) {
|
||||
baseList = baseList.slice(0, 50);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user