From 4e85f72f0ee237bef7a1617e0cf8c811a4091d72 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 4 Aug 2024 10:49:43 +0900 Subject: [PATCH] Fix extra scroll offset in multi-line mode (--read0 or --wrap) Fix #3950 --- src/terminal.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/terminal.go b/src/terminal.go index 09a08985ad2..bbccf1c64e0 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -4850,11 +4850,18 @@ func (t *Terminal) constrain() { linesSum := 0 add := func(i int) bool { - lines, _ := t.numItemLines(t.merger.Get(i).item, numItems-linesSum) + lines, overflow := t.numItemLines(t.merger.Get(i).item, numItems-linesSum) linesSum += lines if linesSum >= numItems { - if numItemsFound == 0 { - numItemsFound = 1 + /* + # Should show all 3 items + printf "file1\0file2\0file3\0" | fzf --height=5 --read0 --bind load:last --reverse + + # Should not truncate the last item + printf "file\n1\0file\n2\0file\n3\0" | fzf --height=5 --read0 --bind load:last --reverse + */ + if numItemsFound == 0 || !overflow { + numItemsFound++ } return false }