summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2022-01-12 19:46:33 +0900
committergit <svn-admin@ruby-lang.org>2022-01-16 22:09:31 +0900
commit921ff739df14c705491d75435c5e5ce31e2ed553 (patch)
treec57d34da85479720c32ff301f0df48c917c12d9d
parentd1e078e71c7a1dcd20c372d4a50b81ea647311e4 (diff)
[ruby/reline] Insert newline in the middle of buffer just after dialog
https://github.com/ruby/reline/commit/0c76631132
-rw-r--r--lib/reline/line_editor.rb1
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb21
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 70be8ac27a..82bd36d4b3 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -476,6 +476,7 @@ class Reline::LineEditor
@just_cursor_moving = false
return
elsif @previous_line_index or new_highest_in_this != @highest_in_this
+ clear_dialog_with_content
rerender_changed_current_line
@previous_line_index = nil
rendered = true
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 60d177d896..4da61c2041 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -1289,6 +1289,27 @@ begin
EOC
end
+ def test_insert_newline_in_the_middle_of_buffer_just_after_dialog
+ start_terminal(10, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
+ write("class A\n def a\n 3\n end\nend")
+ write("\n")
+ write("\C-p\C-p\C-p\C-p\C-p\C-e\C-hS")
+ write("\M-\x0D")
+ write(" 3")
+ close
+ assert_screen(<<~'EOC')
+ prompt> end
+ prompt> end
+ => :a
+ prompt> class S
+ prompt> 3
+ prompt> def a
+ prompt> 3
+ prompt> end
+ prompt> end
+ EOC
+ end
+
def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content