-
-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Description
Greetings! This gem is extremely helpful--thanks for all the work on it! I will definitely open a PR for this issue if I can find the time, but I wanted to at least document this error.
Describe the problem
select works fine with (1) a hash of options but no block OR (2) with an array of options instead of a hash, but breaks with (3) a hash of values and a block.
Steps to reproduce the problem
# (1) just a hash, no block
pry(main)> TTY::Prompt.new.select("select thing", {a:2,b:3})
select thing a
=> 2
# (2) block provided, but not a hash of options
pry(main)> TTY::Prompt.new.select("select thing", [1,2,3]) do |q| puts 'hello'; end
hello
select thing 1
=> 1
# (3) hash of options and block
pry(main)> TTY::Prompt.new.select("select thing", {a:2,b:3}) do |q| puts 'hello'; end
hello
NoMethodError: undefined method `+' for nil:NilClass
@active = choices.index { |choice| !choice.disabled? } + 1
^
from .../.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/tty-prompt-0.23.1/lib/tty/prompt/list.rb:393:in `setup_defaults'
Actual behaviour
NoMethodError: undefined method `+' for nil:NilClass
(Notably, this is the same error that occurs if you pass an empty array or hash as your options.)
Expected behaviour
Allows user to select from provided options
Describe your environment
- OS version: macOS Ventura 13.4
- Ruby version: 3.1
- TTY::Prompt version: 0.23.1
Metadata
Metadata
Assignees
Labels
No labels