Skip to content

Conversation

@ima1zumi
Copy link
Member

This feature displays all possible completions with a single tab press if autocomplete is disabled and multiple completions are available. It does not alter behavior when autocomplete is enabled.

show-all-if-ambiguous
This alters the default behavior of the completion functions. If set to ‘on’, words which have more than one possible completion cause the matches to be listed immediately instead of ringing the bell. The default value is ‘off’.

https://tiswww.case.edu/php/chet/readline/readline.html

To use this feature, add these lines to your .inputrc file and start irb with --noautocomplete:

set show-all-if-ambiguous on 
@ima1zumi ima1zumi added the enhancement New feature or request label Apr 16, 2024
@perfect_matched = completed
else
@completion_state = CompletionState::MENU
complete(list, just_show_list) if @config.show_all_if_ambiguous
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the flow is complex because complete became a recursive method.
How about complete_internal_proc(list, true)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since complete_internal_proc does not change the state of @completion_state, it did not fit this purpose. I decided to call it complete(list, true).

@tompng
Copy link
Member

tompng commented Apr 17, 2024

Looks like this case is missing: 1.ab[TAB]

irb(main):001> 1.abs # partially completed 1.abs 1.abs2 # and ambiguous list are shown 
@ima1zumi ima1zumi force-pushed the show-all-if-ambiguous branch from 93df93e to 84ad9fa Compare April 18, 2024 17:24
@tompng tompng merged commit 0fe4fdc into ruby:master Apr 19, 2024
@ima1zumi ima1zumi deleted the show-all-if-ambiguous branch April 21, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

2 participants