зеркало из https://github.com/github/ruby.git
[ruby/reline] Pass unmodifined lines(that does not include escape
sequence) to check_multiline_prompt (https://github.com/ruby/reline/pull/458) * pass unmodified lines to check_multiline_prompt * Add test to check that output modified by output_modifier_proc is not passed to prompt_proc
This commit is contained in:
Родитель
048751dd73
Коммит
0abb4b6348
|
@ -671,8 +671,10 @@ class Reline::LineEditor
|
|||
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,
|
||||
|
@ -774,8 +776,10 @@ class Reline::LineEditor
|
|||
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,
|
||||
|
@ -785,7 +789,7 @@ class Reline::LineEditor
|
|||
|
||||
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|
|
||||
|
@ -896,7 +900,7 @@ class Reline::LineEditor
|
|||
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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -460,6 +460,18 @@ begin
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче