m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-14 14:23:47 -05:00

Add support for {n} in --with-nth and --accept-nth templates

Close #4275
This commit is contained in:
Junegunn Choi
2025-02-23 19:47:56 +09:00
parent bae1965231
commit 461115afde
5 changed files with 28 additions and 16 deletions

View File

@@ -305,7 +305,7 @@ type Terminal struct {
nthAttr tui.Attr
nth []Range
nthCurrent []Range
acceptNth func([]Token) string
acceptNth func([]Token, int32) string
tabstop int
margin [4]sizeSpec
padding [4]sizeSpec
@@ -1576,7 +1576,7 @@ func (t *Terminal) output() bool {
if t.acceptNth != nil {
transform = func(item *Item) string {
tokens := Tokenize(item.AsString(t.ansi), t.delimiter)
transformed := t.acceptNth(tokens)
transformed := t.acceptNth(tokens, item.Index())
return StripLastDelimiter(transformed, t.delimiter)
}
}