[ruby/reline] Support continuous tab completion
(https://github.com/ruby/reline/pull/761) Continuous tab completion is possible in GNU Readline. If dig_perfect_match_proc is set, continuous tab completion will be disabled. https://github.com/ruby/reline/commit/469a52846b
This commit is contained in:
parent
c12c95462a
commit
98fce00cab
@ -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
|
||||
|
@ -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{
|
||||
|
Loading…
x
Reference in New Issue
Block a user