You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
steamwings
changed the title
select errors when provided a hash and a blockselect errors when provided a hash and a block
Jun 15, 2023
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
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
The text was updated successfully, but these errors were encountered: