diff options
author | aycabta <aycabta@gmail.com> | 2019-05-21 09:14:08 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-21 09:14:08 +0900 |
commit | 29c81265c1637245aa331f8d47c5060f4dc79ab0 (patch) | |
tree | 8191ceb004975b065b2a9eded0ad3c334a963ab3 /lib | |
parent | 3a9008b9845db544d0788851f9527ce9f9f6bf4a (diff) | |
download | ruby-29c81265c1637245aa331f8d47c5060f4dc79ab0.tar.gz |
Check whether IRB.conf is nil in IRB::WorkSpace#code_around_binding
Diffstat (limited to 'lib')
-rw-r--r-- | lib/irb/workspace.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb index bb7407aa0f..9337c172fd 100644 --- a/lib/irb/workspace.rb +++ b/lib/irb/workspace.rb @@ -131,13 +131,17 @@ EOF 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" |