mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Implement vi_yank
https://github.com/ruby/reline/commit/164aaf9a5f
This commit is contained in:
parent
2dc4aca8d1
commit
6be3b2da19
2 changed files with 26 additions and 0 deletions
|
@ -2083,6 +2083,14 @@ class Reline::LineEditor
|
||||||
end
|
end
|
||||||
|
|
||||||
private def vi_yank(key)
|
private def vi_yank(key)
|
||||||
|
@waiting_operator_proc = proc { |cursor_diff, byte_pointer_diff|
|
||||||
|
if byte_pointer_diff > 0
|
||||||
|
cut = @line.byteslice(@byte_pointer, byte_pointer_diff)
|
||||||
|
elsif byte_pointer_diff < 0
|
||||||
|
cut = @line.byteslice(@byte_pointer + byte_pointer_diff, -byte_pointer_diff)
|
||||||
|
end
|
||||||
|
copy_for_vi(cut)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
private def vi_list_or_eof(key)
|
private def vi_list_or_eof(key)
|
||||||
|
|
|
@ -1276,4 +1276,22 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
|
||||||
assert_cursor_max(3)
|
assert_cursor_max(3)
|
||||||
assert_line('abc')
|
assert_line('abc')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_vi_yank
|
||||||
|
input_keys("foo bar\C-[0")
|
||||||
|
assert_line('foo bar')
|
||||||
|
assert_byte_pointer_size('')
|
||||||
|
assert_cursor(0)
|
||||||
|
assert_cursor_max(7)
|
||||||
|
input_keys('y3l')
|
||||||
|
assert_line('foo bar')
|
||||||
|
assert_byte_pointer_size('')
|
||||||
|
assert_cursor(0)
|
||||||
|
assert_cursor_max(7)
|
||||||
|
input_keys('P')
|
||||||
|
assert_line('foofoo bar')
|
||||||
|
assert_byte_pointer_size('fo')
|
||||||
|
assert_cursor(2)
|
||||||
|
assert_cursor_max(10)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue