[前][次][番号順一覧][スレッド一覧]

ruby-changes:70810

From: aycabta <ko1@a...>
Date: Tue, 11 Jan 2022 06:10:48 +0900 (JST)
Subject: [ruby-changes:70810] 9e79ae539b (master): [ruby/reline] Clear dialog when just_move_cursor is called with dialog at last line

https://git.ruby-lang.org/ruby.git/commit/?id=9e79ae539b

From 9e79ae539b6c939af6c3bc1a008a019fb920fe64 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Tue, 4 Jan 2022 14:21:46 +0900
Subject: [ruby/reline] Clear dialog when just_move_cursor is called with
 dialog at last line

https://github.com/ruby/reline/commit/05024b968e
---
 lib/reline/line_editor.rb                   |  6 +++++-
 test/reline/yamatanooroti/test_rendering.rb | 17 +++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 90cc4b2db2f..dc0dcc6bbca 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -470,8 +470,12 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L470
       @add_newline_to_end_of_buffer = false
     else
       if @just_cursor_moving and not @rerender_all
+        @dialogs.each do |dialog|
+          clear_each_dialog(dialog)
+          dialog.contents = nil
+          dialog.trap_key = nil
+        end
         rendered = just_move_cursor
-        render_dialog((prompt_width + @cursor) % @screen_size.last)
         @just_cursor_moving = false
         return
       elsif @previous_line_index or new_highest_in_this != @highest_in_this
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 5b95a14d0e5..a1aab6bfee6 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -1254,6 +1254,23 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L1254
       EOC
     end
 
+    def test_clear_dialog_when_just_move_cursor_at_last_line
+      start_terminal(10, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
+      write("class A\n  3\nend\n")
+      write("\C-p\C-p\C-p\C-e\C-hS")
+      write("\C-n")
+      write("1")
+      close
+      assert_screen(<<~'EOC')
+        prompt>   3
+        prompt> end
+        => 3
+        prompt> class S
+        prompt>   31
+        prompt> end
+      EOC
+    end
+
     def write_inputrc(content)
       File.open(@inputrc_file, 'w') do |f|
         f.write content
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]