mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Suppress crashing when auto_indent_proc returns broken indent info
Co-authored-by: Juanito Fatas <me@juanitofatas.com> https://github.com/ruby/reline/commit/7c24276275
This commit is contained in:
parent
e356b71d35
commit
88af5085db
2 changed files with 15 additions and 0 deletions
|
@ -1131,6 +1131,7 @@ class Reline::LineEditor
|
|||
new_lines = whole_lines
|
||||
end
|
||||
new_indent = @auto_indent_proc.(new_lines, @line_index, @byte_pointer, @check_new_auto_indent)
|
||||
new_indent = @cursor_max if new_indent&.> @cursor_max
|
||||
if new_indent&.>= 0
|
||||
md = new_lines[@line_index].match(/\A */)
|
||||
prev_indent = md[0].count(' ')
|
||||
|
|
|
@ -637,6 +637,20 @@ begin
|
|||
EOC
|
||||
end
|
||||
|
||||
def test_suppress_auto_indent_just_after_pasted
|
||||
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl --auto-indent}, startup_message: 'Multiline REPL.')
|
||||
write("def hoge\n [[\n 3]]\ned")
|
||||
write("\C-bn")
|
||||
close
|
||||
assert_screen(<<~EOC)
|
||||
Multiline REPL.
|
||||
prompt> def hoge
|
||||
prompt> [[
|
||||
prompt> 3]]
|
||||
prompt> end
|
||||
EOC
|
||||
end
|
||||
|
||||
private def write_inputrc(content)
|
||||
File.open(@inputrc_file, 'w') do |f|
|
||||
f.write content
|
||||
|
|
Loading…
Reference in a new issue