Fix --header-lines unaffected by --with-nth
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent 928fccc · Browse files · 3 files·+22 added−6 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+22 added−6 removed
- tests:+13 added−1 removed
- other:+9 added−5 removed
Provenance
- Commit
4e0e034- Tree
4c65010- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
928fccc
3 files changed+22 added−6 removed
modified:man/man1/fzf.1+6 added-2 removed
258 unmodified lines259 automatically truncated when the number of the lines exceeds the value.260 .TP261 .BI "--header-file=" "FILE"262 The content of the file will be printed as the sticky header. The file can263-span multiple lines and can contain ANSI color codes.263+span multiple lines and can contain ANSI color codes. The lines in the file are264+displayed from top to bottom regardless of \fB--reverse\fR, and are265+not affected by \fB--with-nth\fR.266 .TP267 .BI "--header-lines=" "N"266-The first N lines of the input are treated as the sticky header.268+The first N lines of the input are treated as the sticky header. When269+\fB--with-nth\fR is set, the lines are transformed just like the other270+lines that follow.271 .SS Scripting272 .TP273 .BI "-q, --query=" "STR"274 Start the finder with the given query101 unmodified linesmodified:src/core.go+3 added-3 removed
102 unmodified lines103 rank: Rank{0, 0, uint32(index)}}104 })105 } else {106 chunkList = NewChunkList(func(data *string, index int) *Item {107+ tokens := Tokenize(data, opts.Delimiter)108+ trans := Transform(tokens, opts.WithNth)109 if len(header) < opts.HeaderLines {108- header = append(header, *data)110+ header = append(header, *joinTokens(trans))111 eventBox.Set(EvtHeader, header)112 return nil113 }112- tokens := Tokenize(data, opts.Delimiter)113- trans := Transform(tokens, opts.WithNth)114 item := Item{115 text: joinTokens(trans),116 origText: data,117 index: uint32(index),150 unmodified linesmodified:test/test_go.rb+13 added-1 removed
686 unmodified lines687 tmux.send_keys :Enter688 assert_equal '', readonce.chomp689 end690 691+ def test_header_lines_with_nth692+ tmux.send_keys "seq 100 | #{fzf "--header-lines 5 --with-nth 1,1,1,1,1"}", :Enter693+ tmux.until do |lines|694+ lines[-2].include?('95/95') &&695+ lines[-3] == ' 11111' &&696+ lines[-7] == ' 55555' &&697+ lines[-8] == '> 66666'698+ end699+ tmux.send_keys :Enter700+ assert_equal '6', readonce.chomp701+ end702+703 def test_header_file704 tmux.send_keys "seq 100 | #{fzf "--header-file <(head -5 #{__FILE__})"}", :Enter705 header = File.readlines(__FILE__).take(5).map(&:strip)706 tmux.until do |lines|2 unmodified lines709 end710 end711 712 def test_header_file_reverse701- tmux.send_keys "seq 100 | #{fzf "--header-file <(head -5 #{__FILE__}) --reverse"}", :Enter713+ tmux.send_keys "seq 100 | #{fzf "--header-file=<(head -5 #{__FILE__}) --reverse"}", :Enter714 header = File.readlines(__FILE__).take(5).map(&:strip)715 tmux.until do |lines|716 lines[1].include?('100/100') &&717 lines[2..6].map(&:strip) == header244 unmodified lines