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

+23 -9
View File
@@ -98,16 +98,22 @@ func (e *setExpr) eval(app *app, args []string) {
}
app.ui.loadFile(app, true)
}
case "globfilter", "noglobfilter", "globfilter!":
err = applyBoolOpt(&gOpts.globfilter, e)
if err == nil {
app.nav.sort()
app.nav.position()
app.ui.sort()
app.ui.loadFile(app, true)
case "filtermethod":
switch e.val {
case "text", "glob", "regex":
gOpts.filtermethod = searchMethod(e.val)
default:
app.ui.echoerr("filtermethod: value should either be 'text', 'glob' or 'regex")
return
}
app.nav.sort()
app.nav.position()
app.ui.sort()
app.ui.loadFile(app, true)
case "globfilter", "noglobfilter", "globfilter!":
app.ui.echoerr("option 'globfilter' is deprecated, use 'filtermethod' instead")
case "globsearch", "noglobsearch", "globsearch!":
err = applyBoolOpt(&gOpts.globsearch, e)
app.ui.echoerr("option 'globsearch' is deprecated, use 'searchmethod' instead")
case "hidden", "nohidden", "hidden!":
err = applyBoolOpt(&gOpts.hidden, e)
if err == nil {
@@ -302,7 +308,7 @@ func (e *setExpr) eval(app *app, args []string) {
switch s {
case "mode", "timestamps":
default:
app.ui.echoerr("preserve: should consist of 'mode' or 'timestamps separated with colon")
app.ui.echoerr("preserve: should consist of 'mode' or 'timestamps' separated with colon")
return
}
}
@@ -370,6 +376,14 @@ func (e *setExpr) eval(app *app, args []string) {
return
}
gOpts.scrolloff = n
case "searchmethod":
switch e.val {
case "text", "glob", "regex":
gOpts.searchmethod = searchMethod(e.val)
default:
app.ui.echoerr("searchmethod: value should either be 'text', 'glob' or 'regex'")
return
}
case "selectfmt":
gOpts.selectfmt = e.val
case "selmode":