Skip to content

Commit

Permalink
Merge pull request #690 from deivid-rodriguez/rb_readline_does_not_re…
Browse files Browse the repository at this point in the history
…spond_to_call

Restore old check on `completion_proc=`
  • Loading branch information
rafaelfranca committed Nov 11, 2019
2 parents a1b8eaa + fe3c930 commit 45b95a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/thor/line_editor/readline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def self.available?
def readline
if echo?
::Readline.completion_append_character = nil
::Readline.completion_proc = completion_proc
# rb-readline does not allow Readline.completion_proc= to receive nil.
if complete = completion_proc
::Readline.completion_proc = complete
end
::Readline.readline(prompt, add_to_history?)
else
super
Expand Down
4 changes: 2 additions & 2 deletions spec/line_editor/readline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
describe "#readline" do
it "invokes the readline library" do
expect(::Readline).to receive(:readline).with("> ", true).and_return("foo")
expect(::Readline).to receive(:completion_proc=)
expect(::Readline).to_not receive(:completion_proc=)
editor = Thor::LineEditor::Readline.new("> ", {})
expect(editor.readline).to eq("foo")
end

it "supports the add_to_history option" do
expect(::Readline).to receive(:readline).with("> ", false).and_return("foo")
expect(::Readline).to receive(:completion_proc=)
expect(::Readline).to_not receive(:completion_proc=)
editor = Thor::LineEditor::Readline.new("> ", :add_to_history => false)
expect(editor.readline).to eq("foo")
end
Expand Down

0 comments on commit 45b95a3

Please sign in to comment.