From a19ed1623f0341471b90888d02cfcf2601c5f2db Mon Sep 17 00:00:00 2001 From: aycabta Date: Tue, 2 Feb 2021 21:29:20 +0900 Subject: [PATCH] [ruby/reline] The vi_histedit supports multiline This closes ruby/reline#253. https://github.com/ruby/reline/commit/f131f86d71 --- lib/reline/line_editor.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index b21eeababf..84cd8a063e 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -2462,11 +2462,23 @@ class Reline::LineEditor private def vi_histedit(key) path = Tempfile.open { |fp| - fp.write @line + if @is_multiline + fp.write whole_lines.join("\n") + else + fp.write @line + end fp.path } system("#{ENV['EDITOR']} #{path}") - @line = File.read(path) + if @is_multiline + @buffer_of_lines = File.read(path).split("\n") + @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty? + @line_index = 0 + @line = @buffer_of_lines[@line_index] + @rerender_all = true + else + @line = File.read(path) + end finish end