Added another split option
All checks were successful
Build / build (push) Successful in 58s

This commit is contained in:
Leon Mika 2026-01-27 20:57:50 +11:00
parent eda11309bc
commit e679b1607d
2 changed files with 27 additions and 3 deletions

View file

@ -65,17 +65,29 @@ export class CommandsController extends Controller {
_filterOptions(filterText) {
let inputText = filterText.toLowerCase();
let inputTerms = filterText.toLowerCase().split(/\s+/).map(s => s.trim()).filter(s => s !== "");
let visibleOptions = [];
for (let opt of this._options) {
if ((inputText === "") || (opt.innerText.toLowerCase().includes(inputText))) {
if ((inputTerms.length === 0) || (inputTerms.every(term => opt.innerText.toLowerCase().includes(term)))) {
visibleOptions.push(opt);
}
}
let bestMatch = null;
for (let i; i < this._options.length; i++) {
if ((inputTerms.length === 0) || (opt.innerText.toLowerCase().includes(inputText))) {
bestMatch = i;
}
}
this.commandSelectTarget.replaceChildren(...visibleOptions);
if (visibleOptions.length > 0) {
this.commandSelectTarget.selectedIndex = 0;
if (visibleOptions.length > 0) {
if (bestMatch != null) {
this.commandSelectTarget.selectedIndex = bestMatch;
} else {
this.commandSelectTarget.selectedIndex = 0;
}
}
}
}