summaryrefslogtreecommitdiff
path: root/lib/reline
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-12-13 03:57:32 +0900
committeraycabta <aycabta@gmail.com>2019-12-13 08:54:22 +0900
commitc2dfc6d869979124a46fb0c5404956891c27575f (patch)
tree45aa67fb11df82804dcc02d0cb2eb539696d01ae /lib/reline
parentb8d6c883b3f49e6339da4fa5111dbdbe7d3c6df5 (diff)
Show a menu before a document
IRB should show a menu first if a completed list has plural items. But just shows document without menu if a completed list with plural items includes a perfect matched item. The behavior is a bug. This commit fixes it.
Diffstat (limited to 'lib/reline')
-rw-r--r--lib/reline/line_editor.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 5d23c82ded..20d966f6dc 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -43,6 +43,7 @@ class Reline::LineEditor
COMPLETION = :completion
MENU = :menu
JOURNEY = :journey
+ MENU_WITH_PERFECT_MATCH = :menu_with_perfect_match
PERFECT_MATCH = :perfect_match
end
@@ -599,16 +600,24 @@ class Reline::LineEditor
when CompletionState::PERFECT_MATCH
@dig_perfect_match_proc&.(@perfect_matched)
end
- is_menu = (@completion_state == CompletionState::MENU)
+ is_menu = (@completion_state == CompletionState::MENU or @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH)
result = complete_internal_proc(list, is_menu)
+ if @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
+ @completion_state = CompletionState::PERFECT_MATCH
+ end
return if result.nil?
target, preposing, completed, postposing = result
return if completed.nil?
- if target <= completed and (@completion_state == CompletionState::COMPLETION or @completion_state == CompletionState::PERFECT_MATCH)
- @completion_state = CompletionState::MENU
+ if target <= completed and (@completion_state == CompletionState::COMPLETION)
if list.include?(completed)
- @completion_state = CompletionState::PERFECT_MATCH
+ if list.one?
+ @completion_state = CompletionState::PERFECT_MATCH
+ else
+ @completion_state = CompletionState::MENU_WITH_PERFECT_MATCH
+ end
@perfect_matched = completed
+ else
+ @completion_state = CompletionState::MENU
end
if target < completed
@line = preposing + completed + postposing
@@ -622,7 +631,8 @@ class Reline::LineEditor
private def move_completed_list(list, direction)
case @completion_state
- when CompletionState::NORMAL, CompletionState::COMPLETION, CompletionState::MENU
+ when CompletionState::NORMAL, CompletionState::COMPLETION,
+ CompletionState::MENU, CompletionState::MENU_WITH_PERFECT_MATCH
@completion_state = CompletionState::JOURNEY
result = retrieve_completion_block
return if result.nil?