Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,10 @@ def add_dialog_proc(name, p, context = nil)
dialog.set_cursor_pos(cursor_column, @first_line_started_from + @started_from)
dialog_render_info = dialog.call(@last_key)
if dialog_render_info.nil? or dialog_render_info.contents.nil? or dialog_render_info.contents.empty?
lines = whole_lines
dialog.lines_backup = {
lines: modify_lines(whole_lines),
unmodified_lines: lines,
lines: modify_lines(lines),
line_index: @line_index,
first_line_started_from: @first_line_started_from,
started_from: @started_from,
Expand Down Expand Up @@ -772,8 +774,10 @@ def add_dialog_proc(name, p, context = nil)
Reline::IOGate.move_cursor_column(cursor_column)
move_cursor_up(dialog.vertical_offset + dialog.contents.size - 1)
Reline::IOGate.show_cursor
lines = whole_lines
dialog.lines_backup = {
lines: modify_lines(whole_lines),
unmodified_lines: lines,
lines: modify_lines(lines),
line_index: @line_index,
first_line_started_from: @first_line_started_from,
started_from: @started_from,
Expand All @@ -783,7 +787,7 @@ def add_dialog_proc(name, p, context = nil)

private def reset_dialog(dialog, old_dialog)
return if dialog.lines_backup.nil? or old_dialog.contents.nil?
prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:lines])
prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:unmodified_lines])
visual_lines = []
visual_start = nil
dialog.lines_backup[:lines].each_with_index { |l, i|
Expand Down Expand Up @@ -894,7 +898,7 @@ def add_dialog_proc(name, p, context = nil)
private def clear_each_dialog(dialog)
dialog.trap_key = nil
return unless dialog.contents
prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:lines])
prompt, prompt_width, prompt_list = check_multiline_prompt(dialog.lines_backup[:unmodified_lines])
visual_lines = []
visual_lines_under_dialog = []
visual_start = nil
Expand Down
13 changes: 13 additions & 0 deletions test/reline/yamatanooroti/multiline_repl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ opt.on('--dynamic-prompt-with-newline') {
}
}
}
opt.on('--broken-dynamic-prompt-assert-no-escape-sequence') {
Reline.prompt_proc = proc { |lines|
has_escape_sequence = lines.join.include?("\e")
(lines.size + 1).times.map { |i|
has_escape_sequence ? 'error>' : '[%04d]> ' % i
}
}
}
opt.on('--color-bold') {
Reline.output_modifier_proc = ->(output, complete:){
output.gsub(/./) { |c| "\e[1m#{c}\e[0m" }
}
}
opt.on('--auto-indent') {
AutoIndent.new
}
Expand Down
12 changes: 12 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,18 @@ def test_broken_prompt_list
EOC
end

def test_no_escape_sequence_passed_to_dynamic_prompt
start_terminal(10, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete --color-bold --broken-dynamic-prompt-assert-no-escape-sequence}, startup_message: 'Multiline REPL.')
write("%[ S")
write("\n")
close
assert_screen(<<~EOC)
Multiline REPL.
[0000]> %[ S
[0001]>
EOC
end

def test_enable_bracketed_paste
omit if Reline::IOGate.win?
write_inputrc <<~LINES
Expand Down