-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Description
At the prompt, if a user just types TAB, I want to display all completions available. It appears that reline only displays completions if there is something typed at the prompt.
Here is an example that illustrates the issue from ChatGPT:
#!/usr/bin/env ruby
require 'reline'
# Force Emacs mode so that Tab completion is the standard behavior
# (In some Reline versions these are just methods, not setters)
Reline.emacs_editing_mode
# A debug completion function that prints when it's called:
def debug_completion(input)
warn "[DEBUG] completion_proc called with '#{input.inspect}'"
if input.empty?
%w[apple banana cherry]
else
%w[apple banana cherry].grep(/^#{Regexp.escape(input)}/)
end
end
Reline.completion_proc = method(:debug_completion)
loop do
line = Reline.readline("> ", true)
break if line.nil? || line.strip.downcase == "exit"
puts "You typed: #{line}"
end
Hitting TAB and nothing else at the prompt should offer 'apple', 'banana', and 'cherry', but it offers nothing.
Metadata
Metadata
Assignees
Labels
No labels