diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index c42fe66..3dc7177 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -260,10 +260,14 @@ automatically truncated when the number of the lines exceeds the value. .TP .BI "--header-file=" "FILE" The content of the file will be printed as the sticky header. The file can -span multiple lines and can contain ANSI color codes. +span multiple lines and can contain ANSI color codes. The lines in the file are +displayed from top to bottom regardless of \fB--reverse\fR, and are +not affected by \fB--with-nth\fR. .TP .BI "--header-lines=" "N" -The first N lines of the input are treated as the sticky header. +The first N lines of the input are treated as the sticky header. When +\fB--with-nth\fR is set, the lines are transformed just like the other +lines that follow. .SS Scripting .TP .BI "-q, --query=" "STR" diff --git a/src/core.go b/src/core.go index 7a0f119..f3d0680 100644 --- a/src/core.go +++ b/src/core.go @@ -104,13 +104,13 @@ func Run(opts *Options) { }) } else { chunkList = NewChunkList(func(data *string, index int) *Item { + tokens := Tokenize(data, opts.Delimiter) + trans := Transform(tokens, opts.WithNth) if len(header) < opts.HeaderLines { - header = append(header, *data) + header = append(header, *joinTokens(trans)) eventBox.Set(EvtHeader, header) return nil } - tokens := Tokenize(data, opts.Delimiter) - trans := Transform(tokens, opts.WithNth) item := Item{ text: joinTokens(trans), origText: data, diff --git a/test/test_go.rb b/test/test_go.rb index dd113d1..7c5cd80 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -688,6 +688,18 @@ class TestGoFZF < TestBase assert_equal '', readonce.chomp end + def test_header_lines_with_nth + tmux.send_keys "seq 100 | #{fzf "--header-lines 5 --with-nth 1,1,1,1,1"}", :Enter + tmux.until do |lines| + lines[-2].include?('95/95') && + lines[-3] == ' 11111' && + lines[-7] == ' 55555' && + lines[-8] == '> 66666' + end + tmux.send_keys :Enter + assert_equal '6', readonce.chomp + end + def test_header_file tmux.send_keys "seq 100 | #{fzf "--header-file <(head -5 #{__FILE__})"}", :Enter header = File.readlines(__FILE__).take(5).map(&:strip) @@ -698,7 +710,7 @@ class TestGoFZF < TestBase end def test_header_file_reverse - tmux.send_keys "seq 100 | #{fzf "--header-file <(head -5 #{__FILE__}) --reverse"}", :Enter + tmux.send_keys "seq 100 | #{fzf "--header-file=<(head -5 #{__FILE__}) --reverse"}", :Enter header = File.readlines(__FILE__).take(5).map(&:strip) tmux.until do |lines| lines[1].include?('100/100') &&