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

ruby-changes:58294

From: aycabta <ko1@a...>
Date: Fri, 18 Oct 2019 00:46:00 +0900 (JST)
Subject: [ruby-changes:58294] d1a7305848 (master): Insert multiline incremental search result correctly

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

From d1a7305848969128d3eb175a4a3b2d7f7929376a Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 18 Oct 2019 00:41:17 +0900
Subject: Insert multiline incremental search result correctly


diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index c9028c8..0e3544a 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -1122,7 +1122,11 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1122
   alias_method :end_of_line, :ed_move_to_end
 
   private def ed_search_prev_history(key)
-    @line_backup_in_history = @line
+    if @is_multiline
+      @line_backup_in_history = whole_buffer
+    else
+      @line_backup_in_history = @line
+    end
     searcher = Fiber.new do
       search_word = String.new(encoding: @encoding)
       multibyte_buf = String.new(encoding: 'ASCII-8BIT')
@@ -1207,9 +1211,20 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1211
           searcher.resume(key)
         else
           if @history_pointer
-            @line = Reline::HISTORY[@history_pointer]
+            line = Reline::HISTORY[@history_pointer]
+          else
+            line = @line_backup_in_history
+          end
+          if @is_multiline
+            @line_backup_in_history = whole_buffer
+            @buffer_of_lines = line.split("\n")
+            @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
+            @line_index = @buffer_of_lines.size - 1
+            @line = @buffer_of_lines.last
+            @rerender_all = true
           else
-            @line = @line_backup_in_history
+            @line_backup_in_history = @line
+            @line = line
           end
           @searching_prompt = nil
           @waiting_proc = nil
-- 
cgit v0.10.2


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

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