mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Implement J to join lines in vi command mode
This commit is contained in:
parent
64dc21830a
commit
716ba4a127
2 changed files with 16 additions and 1 deletions
|
@ -149,7 +149,7 @@ class Reline::KeyActor::ViCommand < Reline::KeyActor::Base
|
|||
# 73 I
|
||||
:vi_insert_at_bol,
|
||||
# 74 J
|
||||
:ed_search_next_history,
|
||||
:vi_join_lines,
|
||||
# 75 K
|
||||
:ed_search_prev_history,
|
||||
# 76 L
|
||||
|
|
|
@ -40,6 +40,7 @@ class Reline::LineEditor
|
|||
vi_paste_prev
|
||||
vi_paste_next
|
||||
vi_replace_char
|
||||
vi_join_lines
|
||||
}
|
||||
|
||||
VI_OPERATORS = %i{
|
||||
|
@ -1632,4 +1633,18 @@ class Reline::LineEditor
|
|||
end
|
||||
@waiting_proc = nil
|
||||
end
|
||||
|
||||
private def vi_join_lines(key, arg: 1)
|
||||
if @is_multiline and @buffer_of_lines.size > @line_index + 1
|
||||
@cursor = calculate_width(@line)
|
||||
@byte_pointer = @line.bytesize
|
||||
@line += ' ' + @buffer_of_lines.delete_at(@line_index + 1).gsub(/\A +/, '')
|
||||
@cursor_max = calculate_width(@line)
|
||||
@buffer_of_lines[@line_index] = @line
|
||||
@rerender_all = true
|
||||
@rest_height += 1
|
||||
end
|
||||
arg -= 1
|
||||
vi_join_lines(key, arg: arg) if arg > 0
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue