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

Make --accept-nth compatible with --select-1

Fix #4287
This commit is contained in:
Junegunn Choi
2025-02-26 00:24:41 +09:00
parent bb64d84ce4
commit 710ebdf9c1
4 changed files with 22 additions and 4 deletions

View File

@@ -476,8 +476,17 @@ func Run(opts *Options) (int, error) {
if len(opts.Expect) > 0 {
opts.Printer("")
}
transformer := func(item *Item) string {
return item.AsString(opts.Ansi)
}
if opts.AcceptNth != nil {
fn := opts.AcceptNth(opts.Delimiter)
transformer = func(item *Item) string {
return item.acceptNth(opts.Ansi, opts.Delimiter, fn)
}
}
for i := 0; i < count; i++ {
opts.Printer(val.Get(i).item.AsString(opts.Ansi))
opts.Printer(transformer(val.Get(i).item))
}
if count == 0 {
exitCode = ExitNoMatch