Skip to content

Conversation

@amatsuda
Copy link
Member

@amatsuda amatsuda commented Jan 26, 2026

Let me propose to add the "common prefix completion" for the first tab hit on autocompletion mode.
The behavior is similar to the tab hit on non-autocompletion mode, and then it cycles through the candidates just as the current autocompletion mode behaves. I think this is how most of the modern shells e.g., bash, zsh, etc. behave by default.

As a realistic example, when having candidates

instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables

now we can get to "instance_variable_get" with the following three steps:

  1. User hits Tab: Complete to common prefix, "instance_" with menu displayed
  2. User types "v" + Tab: Complete to common prefix, "instance_variable"
  3. User types "_g" + Tab: Complete "instance_variable_get"

You can confirm this exact behavior with this one liner on this branch:
ruby -Ilib -rreline -e "Reline.autocompletion = true; Reline.completion_proc = proc { |s| %w[instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables].select { |i| i.start_with?(s) } }; puts Reline.readline('> ')"

Now the first tab press on autocompletion mode performs common prefix
completion, like the tab press on non-autocompletion mode.

For instance, when having candidates %w[ab1 ab2 ab3 c]:

1. User inputs "a"
2. First Tab: Complete to common prefix (e.g., "a" → "ab" with menu displayed)
3. Second Tab: Select first candidate (e.g., "ab" → "ab1")
4. Subsequent Tabs: Cycle through candidates + common prefix ("ab")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant