summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/reline/line_editor.rb6
-rw-r--r--test/reline/test_key_actor_emacs.rb23
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index e01d859262..f6627ca430 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -846,7 +846,11 @@ class Reline::LineEditor
when CompletionState::NORMAL
@completion_state = CompletionState::COMPLETION
when CompletionState::PERFECT_MATCH
- @dig_perfect_match_proc&.(@perfect_matched)
+ if @dig_perfect_match_proc
+ @dig_perfect_match_proc.(@perfect_matched)
+ else
+ @completion_state = CompletionState::COMPLETION
+ end
end
if just_show_list
is_menu = true
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb
index cd8971298d..2ebd91dc2e 100644
--- a/test/reline/test_key_actor_emacs.rb
+++ b/test/reline/test_key_actor_emacs.rb
@@ -920,6 +920,29 @@ class Reline::KeyActor::EmacsTest < Reline::TestCase
assert_equal('foo_bar', matched)
end
+ def test_continuous_completion_with_perfect_match
+ @line_editor.completion_proc = proc { |word|
+ word == 'f' ? ['foo'] : %w[foobar foobaz]
+ }
+ input_keys('f')
+ input_keys("\C-i", false)
+ assert_line_around_cursor('foo', '')
+ input_keys("\C-i", false)
+ assert_line_around_cursor('fooba', '')
+ end
+
+ def test_continuous_completion_disabled_with_perfect_match
+ @line_editor.completion_proc = proc { |word|
+ word == 'f' ? ['foo'] : %w[foobar foobaz]
+ }
+ @line_editor.dig_perfect_match_proc = proc {}
+ input_keys('f')
+ input_keys("\C-i", false)
+ assert_line_around_cursor('foo', '')
+ input_keys("\C-i", false)
+ assert_line_around_cursor('foo', '')
+ end
+
def test_completion_with_completion_ignore_case
@line_editor.completion_proc = proc { |word|
%w{