summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-07-22 21:24:02 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-07-22 21:24:02 +0900
commit4e0e03403e3ce1d6c0d58c02944e167a8448c792 (patch)
tree4c6501065abac191c3e446ca2e4a168298ba7109
parent928fccc15baf50aafe9ecb50303089361375fb89 (diff)
Fix --header-lines unaffected by --with-nth
-rw-r--r--man/man1/fzf.18
-rw-r--r--src/core.go6
-rw-r--r--test/test_go.rb14
3 files changed, 22 insertions, 6 deletions
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1
index c42fe668..3dc7177b 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 7a0f1199..f3d0680c 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 dd113d1f..7c5cd80e 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') &&