ruby-changes:65171
From: aycabta <ko1@a...>
Date: Sun, 7 Feb 2021 05:16:58 +0900 (JST)
Subject: [ruby-changes:65171] a19ed1623f (master): [ruby/reline] The vi_histedit supports multiline
https://git.ruby-lang.org/ruby.git/commit/?id=a19ed1623f From a19ed1623f0341471b90888d02cfcf2601c5f2db Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Tue, 2 Feb 2021 21:29:20 +0900 Subject: [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 b21eeab..84cd8a0 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -2462,11 +2462,23 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L2462 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/