Fix trailing ␊ not rendered with '--read0 --no-multi-line'

https://github.com/junegunn/fzf/pull/4334#issue-2966013714

    # Should display foo␊
    echo -en "foo\n" | fzf --read0  --no-multi-line
This commit is contained in:
Junegunn Choi 2025-04-11 20:46:49 +09:00
parent 9ffc2c7ca3
commit 0edb5d5ebb
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 6 additions and 1 deletions

View File

@ -3144,7 +3144,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
wasWrapped = true wasWrapped = true
} }
if len(line) > 0 && line[len(line)-1] == '\n' { if len(line) > 0 && line[len(line)-1] == '\n' && lineOffset < len(lines)-1 {
line = line[:len(line)-1] line = line[:len(line)-1]
} else { } else {
wrapped = true wrapped = true

View File

@ -1931,4 +1931,9 @@ class TestCore < TestInteractive
tmux.send_keys :Space tmux.send_keys :Space
tmux.until { |lines| assert lines.any_include?('bar') } tmux.until { |lines| assert lines.any_include?('bar') }
end end
def test_trailing_new_line
tmux.send_keys %(echo -en "foo\n" | fzf --read0 --no-multi-line), :Enter
tmux.until { |lines| assert_includes lines, '> foo␊' }
end
end end