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

ruby-changes:70906

From: aycabta <ko1@a...>
Date: Sun, 16 Jan 2022 22:09:50 +0900 (JST)
Subject: [ruby-changes:70906] f5e3913737 (master): [ruby/reline] Fix incremental search to work correctly even if not last line

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

From f5e3913737916df3bc569dee7d3c9c9ed98146b3 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Thu, 13 Jan 2022 20:29:07 +0900
Subject: [ruby/reline] Fix incremental search to work correctly even if not
 last line

https://github.com/ruby/reline/commit/21d75f6d4c
---
 lib/reline/line_editor.rb                   |  2 ++
 test/reline/yamatanooroti/test_rendering.rb | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 82bd36d4b3d..135432a5d1d 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -2233,6 +2233,8 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L2233
             @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
             @line_index = @buffer_of_lines.size - 1
             @line = @buffer_of_lines.last
+            @byte_pointer = @line.bytesize
+            @cursor = @cursor_max = calculate_width(@line)
             @rerender_all = true
             @searching_prompt = "(%s)`%s'" % [prompt_name, search_word]
           else
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 4da61c20418..c3831121319 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -1310,6 +1310,29 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L1310
       EOC
     end
 
+    def test_incremental_search_on_not_last_line
+      start_terminal(10, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
+      write("def abc\nend\n")
+      write("def def\nend\n")
+      write("\C-p\C-p\C-e")
+      write("\C-r")
+      write("a")
+      write("\n\n")
+      close
+      assert_screen(<<~'EOC')
+        prompt> def abc
+        prompt> end
+        => :abc
+        prompt> def def
+        prompt> end
+        => :def
+        prompt> def abc
+        prompt> end
+        => :abc
+        prompt>
+      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/

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