Skip to content

Commit

Permalink
Fix extra scroll offset in multi-line mode (--read0 or --wrap)
Browse files Browse the repository at this point in the history
Fix #3950
  • Loading branch information
junegunn committed Aug 4, 2024
1 parent dd0737a commit 4e85f72
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4e85f72

Please sign in to comment.