ruby / ruby/reline

Reline not offering completions on empty input

Open
#814 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
311
Forks
99
Avg merge
6d 4h
Merged PRs (30d)
1

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the Ruby/Reline example in the issue and confirm that pressing Tab on an empty prompt offers nothing. Trace Reline's completion handling for empty input; done means the completion_proc is used and the returned apple, banana, and cherry completions are displayed.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.