Skip to content

Commit

Permalink
Check whether IRB.conf is nil in IRB::WorkSpace#code_around_binding
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed May 21, 2019
1 parent 3a9008b commit 29c8126
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/irb/workspace.rb
Expand Up @@ -131,13 +131,17 @@ def code_around_binding
return
end
end
lines = IRB.conf[:MAIN_CONTEXT]&.use_colorize? ? Color.colorize_code(code).lines : code.lines
if IRB.conf&.fetch(:MAIN_CONTEXT, nil)&.use_colorize?
lines = Color.colorize_code(code).lines
else
lines = code.lines
end
pos -= 1

start_pos = [pos - 5, 0].max
end_pos = [pos + 5, lines.size - 1].min

if IRB.conf[:MAIN_CONTEXT]&.use_colorize?
if IRB.conf&.fetch(:MAIN_CONTEXT, nil)&.use_colorize?
fmt = " %2s #{Color.colorize("%#{end_pos.to_s.length}d", [:BLUE, :BOLD])}: %s"
else
fmt = " %2s %#{end_pos.to_s.length}d: %s"
Expand Down

0 comments on commit 29c8126

Please sign in to comment.