Skip to content

Commit 5a0d2c0

Browse files
authored
Don't print useless prompt before escape sequence (#839)
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.
1 parent 5f0327e commit 5a0d2c0

3 files changed

Lines changed: 0 additions & 22 deletions

File tree

lib/reline.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ def readline(prompt = '', add_hist = false)
324324
line_editor.auto_indent_proc = auto_indent_proc
325325
line_editor.dig_perfect_match_proc = dig_perfect_match_proc
326326

327-
# Readline calls pre_input_hook just after printing the first prompt.
328-
line_editor.print_nomultiline_prompt
329327
pre_input_hook&.call
330328

331329
unless Reline::IOGate.dumb?

lib/reline/line_editor.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,6 @@ def render_finished
470470
end
471471
end
472472

473-
def print_nomultiline_prompt
474-
Reline::IOGate.disable_auto_linewrap(true) if Reline::IOGate.win?
475-
# Readline's test `TestRelineAsReadline#test_readline` requires first output to be prompt, not cursor reset escape sequence.
476-
Reline::IOGate.write Reline::Unicode.strip_non_printing_start_end(@prompt) if @prompt && !@is_multiline
477-
ensure
478-
Reline::IOGate.disable_auto_linewrap(false) if Reline::IOGate.win?
479-
end
480-
481473
def render
482474
wrapped_cursor_x, wrapped_cursor_y = wrapped_cursor_position
483475
new_lines = wrapped_prompt_and_input_lines.flatten(1)[screen_scroll_top, screen_height].map do |prompt, line|

test/reline/test_reline.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,6 @@ def test_dumb_terminal
382382
assert_match(/#<Reline::Dumb/, out.chomp)
383383
end
384384

385-
def test_print_prompt_before_everything_else
386-
pend if win?
387-
lib = File.expand_path("../../lib", __dir__)
388-
code = "p Reline::IOGate.class; p Reline.readline 'prompt> '"
389-
out = IO.popen([Reline.test_rubybin, "-I#{lib}", "-rreline", "-e", code], "r+") do |io|
390-
io.write "abc\n"
391-
io.close_write
392-
io.read
393-
end
394-
assert_match(/\AReline::ANSI\nprompt> /, out)
395-
end
396-
397385
def test_read_eof_returns_input
398386
pend if win?
399387
lib = File.expand_path("../../lib", __dir__)

0 commit comments

Comments
 (0)