From 55193ee4dc379d643e91a21b34b75745b90e6aa0 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 25 Feb 2026 00:50:43 +0900 Subject: [PATCH] Fix double subtraction of header lines from FZF_TOTAL_COUNT Close #4692 --- src/terminal.go | 2 +- test/test_core.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/terminal.go b/src/terminal.go index 5187fa04..295c363c 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -1372,7 +1372,7 @@ func (t *Terminal) environImpl(forPreview bool) []string { } } env = append(env, "FZF_INPUT_STATE="+inputState) - env = append(env, fmt.Sprintf("FZF_TOTAL_COUNT=%d", max(0, t.count-t.headerLines))) + env = append(env, fmt.Sprintf("FZF_TOTAL_COUNT=%d", t.count)) env = append(env, fmt.Sprintf("FZF_MATCH_COUNT=%d", t.resultMerger.Length())) env = append(env, fmt.Sprintf("FZF_SELECT_COUNT=%d", len(t.selected))) env = append(env, fmt.Sprintf("FZF_LINES=%d", t.areaLines)) diff --git a/test/test_core.rb b/test/test_core.rb index 2ca9e26e..c3c1fff2 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -1755,7 +1755,7 @@ class TestCore < TestInteractive end end - tmux.send_keys %(seq 100 | #{FZF} --multi --reverse --preview-window 0 --preview 'env | grep ^FZF_ | sort > #{tempname}' --no-input --bind enter:show-input+refresh-preview,space:disable-search+refresh-preview), :Enter + tmux.send_keys %({ echo foo; seq 100; } | #{FZF} --header-lines 1 --multi --reverse --preview-window 0 --preview 'env | grep ^FZF_ | sort > #{tempname}' --no-input --bind enter:show-input+refresh-preview,space:disable-search+refresh-preview), :Enter expected = { FZF_DIRECTION: 'down', FZF_TOTAL_COUNT: '100',