From 399b3b687cdc47ba0fe739ba5ffd13ca565727f2 Mon Sep 17 00:00:00 2001 From: tompng Date: Wed, 9 Jul 2025 01:48:04 +0900 Subject: [PATCH] Don't print useless prompt before escape sequence Reline used to print prompt in nomultiline mode before printing any escape sequence because readline-ext's test was requiring. Removing this behavior because it causes line-wrapped long prompt displayed twice. Test code that depend on this behavior needs to be modified. --- lib/reline.rb | 2 -- lib/reline/line_editor.rb | 8 -------- test/reline/test_reline.rb | 12 ------------ 3 files changed, 22 deletions(-) diff --git a/lib/reline.rb b/lib/reline.rb index 7d0d6745df..c62bf4ebf6 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -324,8 +324,6 @@ def readline(prompt = '', add_hist = false) line_editor.auto_indent_proc = auto_indent_proc line_editor.dig_perfect_match_proc = dig_perfect_match_proc - # Readline calls pre_input_hook just after printing the first prompt. - line_editor.print_nomultiline_prompt pre_input_hook&.call unless Reline::IOGate.dumb? diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index c1c0b5bfdc..763a2171e5 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -470,14 +470,6 @@ def render_finished end end - def print_nomultiline_prompt - Reline::IOGate.disable_auto_linewrap(true) if Reline::IOGate.win? - # Readline's test `TestRelineAsReadline#test_readline` requires first output to be prompt, not cursor reset escape sequence. - Reline::IOGate.write Reline::Unicode.strip_non_printing_start_end(@prompt) if @prompt && !@is_multiline - ensure - Reline::IOGate.disable_auto_linewrap(false) if Reline::IOGate.win? - end - def render wrapped_cursor_x, wrapped_cursor_y = wrapped_cursor_position new_lines = wrapped_prompt_and_input_lines.flatten(1)[screen_scroll_top, screen_height].map do |prompt, line| diff --git a/test/reline/test_reline.rb b/test/reline/test_reline.rb index 8cbf42bada..aa0fd7d29a 100644 --- a/test/reline/test_reline.rb +++ b/test/reline/test_reline.rb @@ -382,18 +382,6 @@ def test_dumb_terminal assert_match(/# /, out) - end - def test_read_eof_returns_input pend if win? lib = File.expand_path("../../lib", __dir__)