[ruby/reline] Fix vi_yank or vi_delete_meta copies nil bug
(https://github.com/ruby/reline/pull/726) https://github.com/ruby/reline/commit/46b30b07c9
This commit is contained in:
parent
b499356307
commit
c2e2c5975d
@ -2259,9 +2259,11 @@ class Reline::LineEditor
|
||||
line, cut = byteslice!(current_line, @byte_pointer, byte_pointer_diff)
|
||||
elsif byte_pointer_diff < 0
|
||||
line, cut = byteslice!(current_line, @byte_pointer + byte_pointer_diff, -byte_pointer_diff)
|
||||
else
|
||||
return
|
||||
end
|
||||
copy_for_vi(cut)
|
||||
set_current_line(line || '', @byte_pointer + (byte_pointer_diff < 0 ? byte_pointer_diff : 0))
|
||||
set_current_line(line, @byte_pointer + (byte_pointer_diff < 0 ? byte_pointer_diff : 0))
|
||||
end
|
||||
|
||||
private def vi_yank(key, arg: nil)
|
||||
@ -2280,6 +2282,8 @@ class Reline::LineEditor
|
||||
cut = current_line.byteslice(@byte_pointer, byte_pointer_diff)
|
||||
elsif byte_pointer_diff < 0
|
||||
cut = current_line.byteslice(@byte_pointer + byte_pointer_diff, -byte_pointer_diff)
|
||||
else
|
||||
return
|
||||
end
|
||||
copy_for_vi(cut)
|
||||
end
|
||||
|
@ -738,6 +738,13 @@ class Reline::ViInsertTest < Reline::TestCase
|
||||
assert_line_around_cursor('aaa ', 'ddd eee')
|
||||
end
|
||||
|
||||
def test_vi_delete_meta_nothing
|
||||
input_keys("foo\C-[0")
|
||||
assert_line_around_cursor('', 'foo')
|
||||
input_keys('dhp')
|
||||
assert_line_around_cursor('', 'foo')
|
||||
end
|
||||
|
||||
def test_vi_delete_meta_with_vi_next_word_at_eol
|
||||
input_keys("foo bar\C-[0w")
|
||||
assert_line_around_cursor('foo ', 'bar')
|
||||
@ -848,6 +855,13 @@ class Reline::ViInsertTest < Reline::TestCase
|
||||
assert_line_around_cursor('foofofoofoo barba', 'ro barbar')
|
||||
end
|
||||
|
||||
def test_vi_yank_nothing
|
||||
input_keys("foo\C-[0")
|
||||
assert_line_around_cursor('', 'foo')
|
||||
input_keys('yhp')
|
||||
assert_line_around_cursor('', 'foo')
|
||||
end
|
||||
|
||||
def test_vi_end_word_with_operator
|
||||
input_keys("foo bar\C-[0")
|
||||
assert_line_around_cursor('', 'foo bar')
|
||||
|
Loading…
x
Reference in New Issue
Block a user