From 456e21c03daa3b45a745b1c044b43076192249fd Mon Sep 17 00:00:00 2001 From: "Abinoam P. Marques Jr" Date: Sat, 1 Jul 2017 22:12:47 -0300 Subject: Fix menu indexing by letter --- lib/highline/menu.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/highline/menu.rb b/lib/highline/menu.rb index a743c4d..d9a2b6e 100644 --- a/lib/highline/menu.rb +++ b/lib/highline/menu.rb @@ -423,8 +423,10 @@ class HighLine def get_item_by_letter(items, selection) item = items.find { |i| i.name == selection } return item if item - l_index = "`" # character before the letter "a" - index = items.map { l_index.succ!.to_s }.index(selection) + + # 97 is the "a" letter at ascii table + # Ex: For "a" it will return 0, and for "c" it will return 2 + index = selection.ord - 97 items[index] end -- cgit v1.2.1