diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-02-12 20:15:04 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-02-12 20:15:04 +0900 |
| commit | 84e2262ad63df2112f16b2a80fc661294c3da45e (patch) | |
| tree | 803f4bf41de9d0011efcc2e29f788ac990fc7c73 /src/core.go | |
| parent | 378137d34a2a11b16c66dff2bf4309c7ce232a94 (diff) | |
| download | fzf-84e2262ad63df2112f16b2a80fc661294c3da45e.tar.gz | |
Make --accept-nth and --with-nth support templates
Diffstat (limited to 'src/core.go')
| -rw-r--r-- | src/core.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/core.go b/src/core.go index 08d9e868..939910b3 100644 --- a/src/core.go +++ b/src/core.go @@ -96,7 +96,7 @@ func Run(opts *Options) (int, error) { var chunkList *ChunkList var itemIndex int32 header := make([]string, 0, opts.HeaderLines) - if len(opts.WithNth) == 0 { + if opts.WithNth == nil { chunkList = NewChunkList(cache, func(item *Item, data []byte) bool { if len(header) < opts.HeaderLines { header = append(header, byteString(data)) @@ -109,6 +109,7 @@ func Run(opts *Options) (int, error) { return true }) } else { + nthTransformer := opts.WithNth(opts.Delimiter) chunkList = NewChunkList(cache, func(item *Item, data []byte) bool { tokens := Tokenize(byteString(data), opts.Delimiter) if opts.Ansi && opts.Theme.Colored && len(tokens) > 1 { @@ -127,15 +128,13 @@ func Run(opts *Options) (int, error) { } } } - trans := Transform(tokens, opts.WithNth) - transformed := JoinTokens(trans) + transformed := nthTransformer(tokens) if len(header) < opts.HeaderLines { header = append(header, transformed) eventBox.Set(EvtHeader, header) return false } item.text, item.colors = ansiProcessor(stringBytes(transformed)) - item.text.TrimTrailingWhitespaces() item.text.Index = itemIndex item.origText = &data itemIndex++ |
