This commit is contained in:
parent
eda11309bc
commit
e679b1607d
|
|
@ -65,17 +65,29 @@ export class CommandsController extends Controller {
|
||||||
|
|
||||||
_filterOptions(filterText) {
|
_filterOptions(filterText) {
|
||||||
let inputText = filterText.toLowerCase();
|
let inputText = filterText.toLowerCase();
|
||||||
|
let inputTerms = filterText.toLowerCase().split(/\s+/).map(s => s.trim()).filter(s => s !== "");
|
||||||
|
|
||||||
let visibleOptions = [];
|
let visibleOptions = [];
|
||||||
for (let opt of this._options) {
|
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);
|
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);
|
this.commandSelectTarget.replaceChildren(...visibleOptions);
|
||||||
if (visibleOptions.length > 0) {
|
if (visibleOptions.length > 0) {
|
||||||
this.commandSelectTarget.selectedIndex = 0;
|
if (bestMatch != null) {
|
||||||
|
this.commandSelectTarget.selectedIndex = bestMatch;
|
||||||
|
} else {
|
||||||
|
this.commandSelectTarget.selectedIndex = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,18 @@ var TextFilters = map[string]TextProcessor{
|
||||||
return TextFilterResponse{Output: strings.Replace(input, ",", "\n", -1)}, nil
|
return TextFilterResponse{Output: strings.Replace(input, ",", "\n", -1)}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"join-lines-with-semicolons": {
|
||||||
|
Label: "Lines: Join with Semicolons",
|
||||||
|
Filter: func(ctx context.Context, input string) (resp TextFilterResponse, err error) {
|
||||||
|
return TextFilterResponse{Output: strings.Replace(input, "\n", ";", -1)}, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"split-lines-on-semicolon": {
|
||||||
|
Label: "Lines: Split on Semicolons",
|
||||||
|
Filter: func(ctx context.Context, input string) (resp TextFilterResponse, err error) {
|
||||||
|
return TextFilterResponse{Output: strings.Replace(input, ";", "\n", -1)}, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
"trim-space": {
|
"trim-space": {
|
||||||
Label: "Lines: Trim Spaces",
|
Label: "Lines: Trim Spaces",
|
||||||
Filter: func(ctx context.Context, input string) (resp TextFilterResponse, err error) {
|
Filter: func(ctx context.Context, input string) (resp TextFilterResponse, err error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue