^D on non-empty line in vi mode behaves like Enter

This commit is contained in:
aycabta 2019-12-25 09:29:46 +09:00
parent 8e6d51e09a
commit 622e47a1db
2 changed files with 14 additions and 9 deletions

View file

@ -1938,9 +1938,11 @@ class Reline::LineEditor
@eof = true
finish
else
# TODO: list
ed_newline(key)
end
end
alias_method :vi_end_of_transmission, :vi_list_or_eof
alias_method :vi_eof_maybe, :vi_list_or_eof
private def ed_delete_next_char(key, arg: 1)
byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)

View file

@ -812,16 +812,19 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
end
def test_vi_list_or_eof
input_keys('a')
assert_byte_pointer_size('a')
assert_cursor(1)
assert_cursor_max(1)
input_keys("\C-d") # quit from inputing
assert_line(nil)
assert(@line_editor.finished?)
end
def test_vi_list_or_eof_with_non_empty_line
input_keys('ab')
assert_byte_pointer_size('ab')
assert_cursor(2)
assert_cursor_max(2)
refute(@line_editor.finished?)
input_keys("\C-d")
assert_line('a')
refute(@line_editor.finished?)
input_keys("\C-h\C-d")
assert_line(nil)
assert_line('ab')
assert(@line_editor.finished?)
end