Fix extra scroll offset in multi-line mode (--read0 or --wrap)

Fix #3950
This commit is contained in:
Junegunn Choi 2024-08-04 10:49:43 +09:00
parent dd0737aac0
commit 4e85f72f0e
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -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
}