Add filtermethod and searchmethod options (#2058)

* Add `filtermethod` and `searchmethod` options

* Rename `re` to `regex`

* Remove `globfilter` and `globsearch` options

* Add completions for `filtermethod` and `searchmethod`

* Update documentation

* Remove unnecessary if statement

* Fix unrelated typo

* Put options in alphabetical order

* Fix typo in documentation

* Rename variable for consistency

---------

Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com>
This commit is contained in:
CatsDeservePetsandJoe Lim authored and GitHub committed 2025-07-26 21:25:45 +10:00
1 parent 23b30ae1ee
commit ab662e6f33
8 files changed
+114 -67

No files matched your search

+12 -4
View File
@@ -35,6 +35,14 @@ func isValidSortMethod(method sortMethod) bool {
const invalidSortErrorMessage = `sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'btime', 'ctime', 'ext' or 'custom'`
type searchMethod string
const (
textSearch searchMethod = "text"
globSearch searchMethod = "glob"
regexSearch searchMethod = "regex"
)
var gOpts struct {
anchorfind bool
autoquit bool
@@ -51,8 +59,8 @@ var gOpts struct {
dirpreviews bool
drawbox bool
dupfilefmt string
globfilter bool
globsearch bool
searchmethod searchMethod
filtermethod searchMethod
hidden bool
icons bool
ignorecase bool
@@ -220,8 +228,8 @@ func init() {
gOpts.cursorparentfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m"
gOpts.cutfmt = "\033[7;31m"
gOpts.globfilter = false
gOpts.globsearch = false
gOpts.filtermethod = textSearch
gOpts.searchmethod = textSearch
gOpts.hidden = false
gOpts.icons = false
gOpts.ignorecase = true