diff options
Diffstat (limited to 'lib/reline/line_editor.rb')
-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 |