зеркало из https://github.com/github/ruby.git
Suppress to crash IRB if completed list has nil
This commit is contained in:
Родитель
50ae8895f3
Коммит
7d991a0571
|
@ -553,7 +553,7 @@ class Reline::LineEditor
|
|||
raise Encoding::CompatibilityError, "#{target.encoding.name} is not comaptible with #{i.encoding.name}"
|
||||
end
|
||||
if @config.completion_ignore_case
|
||||
i&.downcase.start_with?(target.downcase)
|
||||
i&.downcase&.start_with?(target.downcase)
|
||||
else
|
||||
i&.start_with?(target)
|
||||
end
|
||||
|
|
|
@ -1363,6 +1363,51 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
assert_line('abcde foo_o_ ABCDE')
|
||||
end
|
||||
|
||||
def test_completion_with_nil_value
|
||||
@line_editor.completion_proc = proc { |word|
|
||||
%w{
|
||||
foo_foo
|
||||
foo_bar
|
||||
Foo_baz
|
||||
qux
|
||||
}.map { |i|
|
||||
i.encode(@encoding)
|
||||
}.prepend(nil)
|
||||
}
|
||||
@config.completion_ignore_case = true
|
||||
input_keys('fo')
|
||||
assert_byte_pointer_size('fo')
|
||||
assert_cursor(2)
|
||||
assert_cursor_max(2)
|
||||
assert_line('fo')
|
||||
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 Foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
|
||||
input_keys('a')
|
||||
input_keys("\C-i", false)
|
||||
assert_byte_pointer_size('foo_a')
|
||||
assert_cursor(5)
|
||||
assert_cursor_max(5)
|
||||
assert_line('foo_a')
|
||||
input_keys("\C-h", false)
|
||||
input_keys('b')
|
||||
input_keys("\C-i", false)
|
||||
assert_byte_pointer_size('foo_ba')
|
||||
assert_cursor(6)
|
||||
assert_cursor_max(6)
|
||||
assert_line('foo_ba')
|
||||
end
|
||||
|
||||
def test_em_kill_region
|
||||
input_keys('abc def{bbb}ccc ddd ')
|
||||
assert_byte_pointer_size('abc def{bbb}ccc ddd ')
|
||||
|
|
Загрузка…
Ссылка в новой задаче