mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Deduplicate completed items
https://github.com/ruby/reline/commit/2dabf0c786
This commit is contained in:
parent
e16e481385
commit
4af2e4111b
2 changed files with 31 additions and 1 deletions
|
@ -565,7 +565,7 @@ class Reline::LineEditor
|
|||
else
|
||||
i&.start_with?(target)
|
||||
end
|
||||
}
|
||||
}.uniq
|
||||
if is_menu
|
||||
menu(target, list)
|
||||
return nil
|
||||
|
|
|
@ -1281,6 +1281,36 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
assert_equal(%w{foo_foo foo_bar foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
|
||||
end
|
||||
|
||||
def test_completion_duplicated_list
|
||||
@line_editor.completion_proc = proc { |word|
|
||||
%w{
|
||||
foo_foo
|
||||
foo_foo
|
||||
foo_bar
|
||||
}.map { |i|
|
||||
i.encode(@encoding)
|
||||
}
|
||||
}
|
||||
input_keys('foo_')
|
||||
assert_byte_pointer_size('foo_')
|
||||
assert_cursor(4)
|
||||
assert_cursor_max(4)
|
||||
assert_line('foo_')
|
||||
assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
|
||||
input_keys("\C-i", false)
|
||||
assert_byte_pointer_size('foo_')
|
||||
assert_cursor(4)
|
||||
assert_cursor_max(4)
|
||||
assert_line('foo_')
|
||||
assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
|
||||
input_keys("\C-i", false)
|
||||
assert_byte_pointer_size('foo_')
|
||||
assert_cursor(4)
|
||||
assert_cursor_max(4)
|
||||
assert_line('foo_')
|
||||
assert_equal(%w{foo_foo foo_bar}, @line_editor.instance_variable_get(:@menu_info).list)
|
||||
end
|
||||
|
||||
def test_completion
|
||||
@line_editor.completion_proc = proc { |word|
|
||||
%w{
|
||||
|
|
Loading…
Add table
Reference in a new issue