diff options
author | aycabta <aycabta@gmail.com> | 2019-10-18 00:41:17 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-10-18 00:44:56 +0900 |
commit | d1a7305848969128d3eb175a4a3b2d7f7929376a (patch) | |
tree | a160a3093976a28da656ca07517f367aeff3714f /lib | |
parent | 4f13927f1fe06a5fe23e25448d9adc80031e0bad (diff) | |
download | bundler-d1a7305848969128d3eb175a4a3b2d7f7929376a.tar.gz |
Insert multiline incremental search result correctly
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index c9028c8c91..0e3544acfe 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1122,7 +1122,11 @@ class Reline::LineEditor 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 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 |