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

Merge pull request #4363 from al-wi/profile-filter-terms

Profile filter per search term instead of the entire search input
This commit is contained in:
Eugeny 2021-08-06 10:09:21 +02:00 committed by GitHub
commit e2c8093b97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)