Skip to content

Commit

Permalink
The vi_histedit supports multiline
Browse files Browse the repository at this point in the history
This closes #253.
  • Loading branch information
aycabta committed Feb 2, 2021
1 parent ba06e4c commit f131f86
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2444,11 +2444,23 @@ def finish

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

Expand Down

0 comments on commit f131f86

Please sign in to comment.