Add change-nth action

Example:
  # Start with --nth 1, then 2, then 3, then back to the default, 1
  echo 'foo foobar foobarbaz' | fzf --bind 'space:change-nth(2|3|)' --nth 1 -q foo

Close #4172
Close #3109
This commit is contained in:
Junegunn Choi
2025-01-13 00:13:31 +09:00
parent 6f943112a9
commit d83eb2800a
7 changed files with 163 additions and 102 deletions

View File

@@ -1306,7 +1306,7 @@ const (
func init() {
executeRegexp = regexp.MustCompile(
`(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform)-(?:query|prompt|(?:border|list|preview|input|header)-label|header)|transform|change-(?:preview-window|preview|multi)|(?:re|un)bind|pos|put|print)`)
`(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform)-(?:query|prompt|(?:border|list|preview|input|header)-label|header)|transform|change-(?:preview-window|preview|multi|nth)|(?:re|un)bind|pos|put|print)`)
splitRegexp = regexp.MustCompile("[,:]+")
actionNameRegexp = regexp.MustCompile("(?i)^[a-z-]+")
}
@@ -1684,6 +1684,8 @@ func isExecuteAction(str string) actionType {
return actChangeQuery
case "change-multi":
return actChangeMulti
case "change-nth":
return actChangeNth
case "pos":
return actPosition
case "execute":