1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Suppress auto indent for adding newlines in pasting

Co-authored-by: Juanito Fatas <me@juanitofatas.com>

074bb017a7
This commit is contained in:
aycabta 2021-01-06 03:50:19 +09:00
parent 76c9a3c8c6
commit 01235f800f
2 changed files with 16 additions and 1 deletions

View file

@ -1339,7 +1339,7 @@ class Reline::LineEditor
cursor_line = @line.byteslice(0, @byte_pointer)
insert_new_line(cursor_line, next_line)
@cursor = 0
@check_new_auto_indent = true
@check_new_auto_indent = true unless Reline::IOGate.in_pasting?
end
end

View file

@ -663,6 +663,21 @@ begin
EOC
end
def test_suppress_auto_indent_for_adding_newlines_in_pasting
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl --auto-indent}, startup_message: 'Multiline REPL.')
write("<<~Q\n")
write("{\n #\n}")
write("#")
close
assert_screen(<<~EOC)
Multiline REPL.
prompt> <<~Q
prompt> {
prompt> #
prompt> }#
EOC
end
private def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content