From 7d991a0571ab33f44c00fdc227f076d1eaf5fb2b Mon Sep 17 00:00:00 2001 From: aycabta Date: Thu, 12 Dec 2019 08:40:44 +0900 Subject: Suppress to crash IRB if completed list has nil --- test/reline/test_key_actor_emacs.rb | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'test') diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index cd5b926afe..4e3184bd3f 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -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 ') -- cgit v1.2.3