diff options
author | aycabta <aycabta@gmail.com> | 2021-02-02 21:29:20 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2021-02-07 05:11:54 +0900 |
commit | a19ed1623f0341471b90888d02cfcf2601c5f2db (patch) | |
tree | b25d4be0ed9c3bdfc85798ed2312b811aa616d70 /lib/reline/line_editor.rb | |
parent | a608bb3e9b13e81940ffbda5cdc30ad373aaa7a5 (diff) | |
download | ruby-a19ed1623f0341471b90888d02cfcf2601c5f2db.tar.gz |
[ruby/reline] The vi_histedit supports multiline
This closes ruby/reline#253.
https://github.com/ruby/reline/commit/f131f86d71
Diffstat (limited to 'lib/reline/line_editor.rb')
-rw-r--r-- | lib/reline/line_editor.rb | 16 |
1 files 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 |