1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-02 02:23:12 +03:00

Filter per search term instead of the entire search input

This commit is contained in:
Alexander Wiedemann 2021-08-06 09:55:15 +02:00
parent 533837f5b7
commit ec2982b1c4

View File

@ -50,8 +50,9 @@ export class SelectorModalComponent<T> {
if (!f) {
this.filteredOptions = this.options.filter(x => !x.freeInputPattern)
} else {
const terms = f.split(' ')
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
this.filteredOptions = this.options.filter(x => x.freeInputPattern ?? (x.name + (x.description ?? '')).toLowerCase().includes(f))
this.filteredOptions = this.options.filter(x => x.freeInputPattern ?? terms.every(term => (x.name + (x.description ?? '')).toLowerCase().includes(term)))
}
this.selectedIndex = Math.max(0, this.selectedIndex)
this.selectedIndex = Math.min(this.filteredOptions.length - 1, this.selectedIndex)