Skip to content

Commit

Permalink
Hack for readline test. (TODO: fix ext-readline's test)
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Oct 24, 2023
1 parent b6cb79a commit e703d15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def readline(prompt = '', add_hist = false)
io_gate.set_default_key_bindings(config)
end

line_editor.print_nomultiline_prompt(prompt)
line_editor.rerender

begin
Expand Down
8 changes: 8 additions & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,14 @@ def render_full_content
@output.puts wrapped_lines.flatten.map { |l| "#{l}\r\n" }.join
end

def print_nomultiline_prompt(prompt)
return unless prompt && !@is_multiline

# Readline's test `TestRelineAsReadline#test_readline` requires first output to be prompt, not cursor reset escape sequence.
@rendered_screen_cache = [[[0, Reline::Unicode.calculate_width(prompt, true), prompt]]]
@output.write prompt
end

def render_differential
unless @dialog_initialzed
update_dialogs
Expand Down

0 comments on commit e703d15

Please sign in to comment.