Fix check for invalid filters (#2231)

* Fix check for invalid filters

* Update `CHANGELOG.md`
This commit is contained in:
Joe Lim authored and GitHub committed 2025-10-27 19:20:21 +11:00
1 parent 887da5d5e4
commit 7776e73334
2 files changed
+9 -4

No files matched your search

+1
View File
@@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- A bug where an empty `custom` info property would still take up space is now fixed (#2208). - A bug where an empty `custom` info property would still take up space is now fixed (#2208).
- A bug where setting `drawbox` could lead to scrolling outside the view is now fixed (#2210) (#2218). - A bug where setting `drawbox` could lead to scrolling outside the view is now fixed (#2210) (#2218).
- The preview cache is now not cleared when setting `ratios` to its current value (#2218). - The preview cache is now not cleared when setting `ratios` to its current value (#2218).
- Filtering is fixed when using special characters in the search pattern if the `filtermethod` is `text` (#2231).
## [r38](https://github.com/gokcehan/lf/releases/tag/r38) ## [r38](https://github.com/gokcehan/lf/releases/tag/r38)
+8 -4
View File
@@ -958,14 +958,18 @@ func (nav *nav) sort() {
func (nav *nav) setFilter(filter []string) error { func (nav *nav) setFilter(filter []string) error {
newfilter := []string{} newfilter := []string{}
for _, tok := range filter { for _, tok := range filter {
_, err := filepath.Match(tok, "a") if tok == "" {
if err != nil { continue
}
// check if filter is valid by applying it to a dummy string
if _, err := searchMatch("a", strings.TrimPrefix(tok, "!"), gOpts.filtermethod); err != nil {
return err return err
} }
if tok != "" {
newfilter = append(newfilter, tok) newfilter = append(newfilter, tok)
} }
}
dir := nav.currDir() dir := nav.currDir()
dir.filter = newfilter dir.filter = newfilter