From 0edb5d5ebb22b160cb289b36fea475073813a1a2 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 11 Apr 2025 20:46:49 +0900 Subject: [PATCH] =?UTF-8?q?Fix=20trailing=20=E2=90=8A=20not=20rendered=20w?= =?UTF-8?q?ith=20'--read0=20--no-multi-line'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/junegunn/fzf/pull/4334#issue-2966013714 # Should display foo␊ echo -en "foo\n" | fzf --read0 --no-multi-line --- src/terminal.go | 2 +- test/test_core.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/terminal.go b/src/terminal.go index f3a7fe4d..e1d14adc 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -3144,7 +3144,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat 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] } else { wrapped = true diff --git a/test/test_core.rb b/test/test_core.rb index f8a182f8..517c94d6 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -1931,4 +1931,9 @@ class TestCore < TestInteractive tmux.send_keys :Space tmux.until { |lines| assert lines.any_include?('bar') } 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