mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Suppress crashing when dynamic_prompt_proc returns a broken prompt list
Co-authored-by: Juanito Fatas <me@juanitofatas.com>
558f7be168
This commit is contained in:
parent
88af5085db
commit
76c9a3c8c6
2 changed files with 19 additions and 0 deletions
|
@ -112,6 +112,7 @@ class Reline::LineEditor
|
|||
use_cached_prompt_list = true
|
||||
end
|
||||
end
|
||||
use_cached_prompt_list = false if @rerender_all
|
||||
if use_cached_prompt_list
|
||||
prompt_list = @cached_prompt_list
|
||||
else
|
||||
|
@ -123,6 +124,12 @@ class Reline::LineEditor
|
|||
prompt_list = prompt_list.map{ |pr| mode_string + pr } if mode_string
|
||||
prompt = prompt_list[@line_index]
|
||||
prompt = prompt_list[0] if prompt.nil?
|
||||
prompt = prompt_list.last if prompt.nil?
|
||||
if buffer.size > prompt_list.size
|
||||
(buffer.size - prompt_list.size).times do
|
||||
prompt_list << prompt_list.last
|
||||
end
|
||||
end
|
||||
prompt_width = calculate_width(prompt, true)
|
||||
[prompt, prompt_width, prompt_list]
|
||||
else
|
||||
|
|
|
@ -450,6 +450,18 @@ begin
|
|||
EOC
|
||||
end
|
||||
|
||||
def test_broken_prompt_list
|
||||
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl --broken-dynamic-prompt}, startup_message: 'Multiline REPL.')
|
||||
write("def hoge\n 3\nend")
|
||||
close
|
||||
assert_screen(<<~EOC)
|
||||
Multiline REPL.
|
||||
[0000]> def hoge
|
||||
[0001]> 3
|
||||
[0001]> end
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_enable_bracketed_paste
|
||||
omit if Reline::IOGate.win?
|
||||
write_inputrc <<~LINES
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue