Skip to content

Commit

Permalink
Add waiting_proc and vi_waiting_operator test
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Mar 19, 2024
1 parent 0aa9d27 commit 3d40721
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
11 changes: 11 additions & 0 deletions test/reline/test_key_actor_emacs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,17 @@ def test_ed_search_next_history_with_empty
assert_line('')
end

def test_incremental_search_history_cancel_by_symbol_key
# ed_prev_char should move cursor left and cancel incremental search
input_keys("abc\C-rdef")
input_key_by_symbol(:ed_prev_char)
input_keys("g")
assert_byte_pointer_size('abg')
assert_cursor(3)
assert_cursor_max(4)
assert_line('abgc')
end

# Unicode emoji test
def test_ed_insert_for_include_zwj_emoji
omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8
Expand Down
57 changes: 56 additions & 1 deletion test/reline/test_key_actor_vi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,20 @@ def test_vi_delete_meta_with_arg
assert_byte_pointer_size('aaa bbb ')
assert_cursor(8)
assert_cursor_max(9)
assert_line('aaa bbb c')
input_keys('d2h')
assert_byte_pointer_size('aaa bb')
assert_cursor(6)
assert_cursor_max(7)
assert_line('aaa bbc')
input_keys('2d3h')
assert_byte_pointer_size('aaa')
assert_cursor(3)
assert_cursor_max(4)
assert_line('aaac')
input_keys('dd')
assert_line('')
assert_cursor(0)
assert_cursor_max(0)
end

def test_vi_change_meta
Expand Down Expand Up @@ -1297,6 +1310,48 @@ def test_vi_change_meta_with_vi_next_word
assert_line('foo hoge baz')
end


def test_vi_waiting_operator_cancel
input_keys("aaa bbb ccc\C-[02w")
assert_byte_pointer_size('aaa bbb ')
assert_cursor(8)
assert_cursor_max(11)
assert_line('aaa bbb ccc')
# dc dy should cancel delete_meta
# cd cy should cancel change_meta
# yd yc yy should cancel yank_meta
# p should not paste yanked text because yank_meta is canceled
input_keys('dchdyhcdhcyhydhychyyhp')
assert_byte_pointer_size('a')
assert_cursor(1)
assert_cursor_max(11)
assert_line('aaa bbb ccc')
end

def test_cancel_waiting_with_symbol_key
input_keys("aaa bbb lll\C-[0")
assert_byte_pointer_size('')
assert_cursor(0)
assert_cursor_max(11)
assert_line('aaa bbb lll')
# ed_next_char should move cursor right and cancel vi_next_char
input_keys('f')
input_key_by_symbol(:ed_next_char)
input_keys('l')
assert_byte_pointer_size('aa')
assert_cursor(2)
assert_cursor_max(11)
assert_line('aaa bbb lll')
# ed_next_char should move cursor right and cancel delete_meta
input_keys('d')
input_key_by_symbol(:ed_next_char)
input_keys('l')
assert_byte_pointer_size('aaa ')
assert_cursor(4)
assert_cursor_max(11)
assert_line('aaa bbb lll')
end

def test_unimplemented_vi_command_should_be_no_op
input_keys("abc\C-[h")
assert_byte_pointer_size('a')
Expand Down

0 comments on commit 3d40721

Please sign in to comment.