From df0fd06d128af77565014f0307fab06dcfc20bdc Mon Sep 17 00:00:00 2001 From: "Abinoam P. Marques Jr." Date: Mon, 15 Jul 2024 09:29:56 -0300 Subject: [PATCH] Fix #271 - Readline completely deprecated in Ruby 3.3 --- lib/highline/terminal.rb | 4 ++-- test/acceptance/at_readline.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/highline/terminal.rb b/lib/highline/terminal.rb index b98a7a6d..7e0078fb 100644 --- a/lib/highline/terminal.rb +++ b/lib/highline/terminal.rb @@ -112,7 +112,7 @@ def get_line_with_readline(question, highline) def readline_read(question, highline) # prep auto-completion unless question.selection.empty? - Readline.completion_proc = lambda do |str| + Reline.completion_proc = lambda do |str| question.selection.grep(/\A#{Regexp.escape(str)}/) end end @@ -124,7 +124,7 @@ def readline_read(question, highline) raw_answer = run_preserving_stty do prompt = highline.render_and_ident_statement(question) - Readline.readline(prompt, true) + Reline.readline(prompt, true) end $VERBOSE = old_verbose diff --git a/test/acceptance/at_readline.rb b/test/acceptance/at_readline.rb index 51673946..fd5a63a4 100644 --- a/test/acceptance/at_readline.rb +++ b/test/acceptance/at_readline.rb @@ -17,7 +17,7 @@ "that begins with the 'l' letter in this particular case.\n\n" \ "If I don't type any character but press two times, I should\n" \ "be able to see ALL available options.\n\n" \ - "Please, play with Readline autocomplete for a while, pressing \n" \ + "Please, play with Reline autocomplete for a while, pressing \n" \ "to see that it really gets the selected answer.\n" \ "When ready, just type 'exit' and the loop will finish.\n\n" \ "Don't forget to answer 'y' (yes) or 'n' (no) to the question at the end." @@ -33,5 +33,5 @@ end end - t.question = "Did the Readline autocomplete work fine (y/n)? " + t.question = "Did the Reline autocomplete work fine (y/n)? " end