Skip to content

Commit 661e9da

Browse files
committed
Hack for readline test. (TODO: fix ext-readline's test)
1 parent f3e1df5 commit 661e9da

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/reline.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def readline(prompt = '', add_hist = false)
341341
io_gate.set_default_key_bindings(config)
342342
end
343343

344+
line_editor.print_nomultiline_prompt(prompt)
344345
line_editor.rerender
345346

346347
begin

lib/reline/line_editor.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,14 @@ def render_full_content
414414
@output.puts wrapped_lines.flatten.map { |l| "#{l}\r\n" }.join
415415
end
416416

417+
def print_nomultiline_prompt(prompt)
418+
return unless prompt && !@is_multiline
419+
420+
# Readline's test `TestRelineAsReadline#test_readline` requires first output to be prompt, not cursor reset escape sequence.
421+
@rendered_screen_cache = [[[0, Reline::Unicode.calculate_width(prompt, true), prompt]]]
422+
@output.write prompt
423+
end
424+
417425
def render_differential
418426
unless @dialog_initialzed
419427
update_dialogs

0 commit comments

Comments
 (0)