mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-15 04:05:48 -07:00
Fix wrapping of the list section
# The first line of the second chunk would prematurely wrap printf '%0500s\n\n%0500s' 0 0 | fzf --wrap --read0
This commit is contained in:
@@ -294,9 +294,10 @@ func (chars *Chars) Lines(multiLine bool, maxLines int, wrapCols int, wrapSignWi
|
|||||||
line = line[:len(line)-1]
|
line = line[:len(line)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasWrapSign := false
|
||||||
for {
|
for {
|
||||||
cols := wrapCols
|
cols := wrapCols
|
||||||
if len(wrapped) > 0 {
|
if hasWrapSign {
|
||||||
cols -= wrapSignWidth
|
cols -= wrapSignWidth
|
||||||
}
|
}
|
||||||
_, overflowIdx := RunesWidth(line, 0, tabstop, cols)
|
_, overflowIdx := RunesWidth(line, 0, tabstop, cols)
|
||||||
@@ -309,9 +310,11 @@ func (chars *Chars) Lines(multiLine bool, maxLines int, wrapCols int, wrapSignWi
|
|||||||
return wrapped, true
|
return wrapped, true
|
||||||
}
|
}
|
||||||
wrapped = append(wrapped, line[:overflowIdx])
|
wrapped = append(wrapped, line[:overflowIdx])
|
||||||
|
hasWrapSign = true
|
||||||
line = line[overflowIdx:]
|
line = line[overflowIdx:]
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
hasWrapSign = false
|
||||||
|
|
||||||
// Restore trailing '\n'
|
// Restore trailing '\n'
|
||||||
if newline {
|
if newline {
|
||||||
|
@@ -76,7 +76,7 @@ func TestCharsLines(t *testing.T) {
|
|||||||
check(true, 100, 3, 1, 1, 8, false)
|
check(true, 100, 3, 1, 1, 8, false)
|
||||||
|
|
||||||
// With wrap sign (3 + 2)
|
// With wrap sign (3 + 2)
|
||||||
check(true, 100, 3, 2, 1, 12, false)
|
check(true, 100, 3, 2, 1, 10, false)
|
||||||
|
|
||||||
// With wrap sign (3 + 2) and no multi-line
|
// With wrap sign (3 + 2) and no multi-line
|
||||||
check(false, 100, 3, 2, 1, 13, false)
|
check(false, 100, 3, 2, 1, 13, false)
|
||||||
|
Reference in New Issue
Block a user