ruby-changes:64792
From: aycabta <ko1@a...>
Date: Fri, 8 Jan 2021 13:38:43 +0900 (JST)
Subject: [ruby-changes:64792] 01235f800f (master): [ruby/reline] Suppress auto indent for adding newlines in pasting
https://git.ruby-lang.org/ruby.git/commit/?id=01235f800f From 01235f800f953cf5c3410d7eab3744c5fa6156e9 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Wed, 6 Jan 2021 03:50:19 +0900 Subject: [ruby/reline] Suppress auto indent for adding newlines in pasting Co-authored-by: Juanito Fatas <me@j...> https://github.com/ruby/reline/commit/074bb017a7 diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 65004ca..31211cd 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1339,7 +1339,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1339 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 diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 9c8df1f..f4a5919 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -663,6 +663,21 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L663 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/