ruby-changes:63916
From: aycabta <ko1@a...>
Date: Sat, 5 Dec 2020 03:09:07 +0900 (JST)
Subject: [ruby-changes:63916] 4af2e4111b (master): [ruby/reline] Deduplicate completed items
https://git.ruby-lang.org/ruby.git/commit/?id=4af2e4111b From 4af2e4111b0e351464a62c73e4ea0ef8b27c43f5 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Wed, 14 Oct 2020 23:29:17 +0900 Subject: [ruby/reline] Deduplicate completed items https://github.com/ruby/reline/commit/2dabf0c786 diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 9bdccae..e5ecc8b 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -565,7 +565,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L565 else i&.start_with?(target) end - } + }.uniq if is_menu menu(target, list) return nil diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index a1e4015..7bb5ac3 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -1281,6 +1281,36 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_key_actor_emacs.rb#L1281 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{ -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/