Skip to content

Commit

Permalink
restore support for IRB <= v1.13.0 (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
sealocal authored Dec 3, 2024
1 parent aa7cd9c commit 36720b7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/iruby/backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,29 @@ def initialize
@irb = IRB::Irb.new(@workspace)
@eval_path = @irb.context.irb_path
IRB.conf[:MAIN_CONTEXT] = @irb.context
@completor = IRB::RegexpCompletor.new
@completor = IRB::RegexpCompletor.new if defined? IRB::RegexpCompletor # IRB::VERSION >= 1.8.2
end

def eval_binding
@workspace.binding
end

def eval(code, store_history)
@irb.context.evaluate(@irb.build_statement(code), 0)
if Gem::Version.new(IRB::VERSION) < Gem::Version.new('1.13.0')
@irb.context.evaluate(code, 0)
else
@irb.context.evaluate(@irb.build_statement(code), 0)
end
@irb.context.last_value unless IRuby.silent_assignment && assignment_expression?(code)
end

def complete(code)
# preposing and postposing never used, so they are empty, pass only target as code
@completor.completion_candidates('', code, '', bind: @workspace.binding)
if @completor
# preposing and postposing never used, so they are empty, pass only target as code
@completor.completion_candidates('', code, '', bind: @workspace.binding)
else
IRB::InputCompletor::CompletionProc.call(code)
end
end

private
Expand Down

0 comments on commit 36720b7

Please sign in to comment.