From 710ebdf9c14e0c88b0cfc843ce08edcdd4554571 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 26 Feb 2025 00:24:41 +0900 Subject: Make --accept-nth compatible with --select-1 Fix #4287 --- src/item.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/item.go') diff --git a/src/item.go b/src/item.go index ca32f1bd..19f0498e 100644 --- a/src/item.go +++ b/src/item.go @@ -51,3 +51,9 @@ func (item *Item) AsString(stripAnsi bool) string { } return item.text.ToString() } + +func (item *Item) acceptNth(stripAnsi bool, delimiter Delimiter, transformer func([]Token, int32) string) string { + tokens := Tokenize(item.AsString(stripAnsi), delimiter) + transformed := transformer(tokens, item.Index()) + return StripLastDelimiter(transformed, delimiter) +} -- cgit v1.2.3