diff options
Diffstat (limited to 'test/reline')
-rw-r--r-- | test/reline/test_key_actor_emacs.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 4e3184bd3f..7ffa28ec87 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -1287,6 +1287,72 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase assert_line('foo_ba') end + def test_completion_with_perfect_match + @line_editor.completion_proc = proc { |word| + %w{ + foo + foo_bar + }.map { |i| + i.encode(@encoding) + } + } + matched = nil + @line_editor.dig_perfect_match_proc = proc { |m| + matched = m + } + input_keys('fo') + assert_byte_pointer_size('fo') + assert_cursor(2) + assert_cursor_max(2) + assert_line('fo') + assert_equal(Reline::LineEditor::CompletionState::NORMAL, @line_editor.instance_variable_get(:@completion_state)) + assert_equal(nil, matched) + input_keys("\C-i", false) + assert_byte_pointer_size('foo') + assert_cursor(3) + assert_cursor_max(3) + assert_line('foo') + assert_equal(Reline::LineEditor::CompletionState::MENU_WITH_PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) + assert_equal(nil, matched) + input_keys("\C-i", false) + assert_byte_pointer_size('foo') + assert_cursor(3) + assert_cursor_max(3) + assert_line('foo') + assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) + assert_equal(nil, matched) + input_keys("\C-i", false) + assert_byte_pointer_size('foo') + assert_cursor(3) + assert_cursor_max(3) + assert_line('foo') + assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) + assert_equal('foo', matched) + matched = nil + input_keys('_') + input_keys("\C-i", false) + assert_byte_pointer_size('foo_bar') + assert_cursor(7) + assert_cursor_max(7) + assert_line('foo_bar') + assert_equal(Reline::LineEditor::CompletionState::MENU_WITH_PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) + assert_equal(nil, matched) + input_keys("\C-i", false) + assert_byte_pointer_size('foo_bar') + assert_cursor(7) + assert_cursor_max(7) + assert_line('foo_bar') + assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) + assert_equal(nil, matched) + input_keys("\C-i", false) + assert_byte_pointer_size('foo_bar') + assert_cursor(7) + assert_cursor_max(7) + assert_line('foo_bar') + assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) + assert_equal('foo_bar', matched) + end + def test_completion_with_completion_ignore_case @line_editor.completion_proc = proc { |word| %w{ |