Skip to content

Commit

Permalink
Suppress auto indent for adding newlines in pasting
Browse files Browse the repository at this point in the history
Co-authored-by: Juanito Fatas <me@juanitofatas.com>
  • Loading branch information
aycabta and JuanitoFatas committed Jan 5, 2021
1 parent 558f7be commit 074bb01
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ def finish
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

Expand Down
15 changes: 15 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,21 @@ def test_suppress_auto_indent_just_after_pasted
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
Expand Down

0 comments on commit 074bb01

Please sign in to comment.