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 25, 2024
1 parent da24881 commit 59c63c9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/reline/test_key_actor_emacs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,14 @@ def test_ed_search_next_history_with_empty
assert_line_around_cursor('', '')
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_line_around_cursor('abg', 'c')
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
33 changes: 33 additions & 0 deletions test/reline/test_key_actor_vi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,12 @@ def test_vi_delete_meta_with_arg
assert_line_around_cursor('aaa bbb ', 'ccc')
input_keys('2dl')
assert_line_around_cursor('aaa bbb ', 'c')
input_keys('d2h')
assert_line_around_cursor('aaa bb', 'c')
input_keys('2d3h')
assert_line_around_cursor('aaa', 'c')
input_keys('dd')
assert_line_around_cursor('', '')
end

def test_vi_change_meta
Expand All @@ -719,6 +725,33 @@ def test_vi_change_meta_with_vi_next_word
assert_line_around_cursor('foo hog', 'e baz')
end


def test_vi_waiting_operator_cancel
input_keys("aaa bbb ccc\C-[02w")
assert_line_around_cursor('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_line_around_cursor('a', 'aa bbb ccc')
end

def test_cancel_waiting_with_symbol_key
input_keys("aaa bbb lll\C-[0")
assert_line_around_cursor('', '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_line_around_cursor('aa', 'a 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_line_around_cursor('aaa ', 'bbb lll')
end

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

0 comments on commit 59c63c9

Please sign in to comment.