aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb/color.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-12-28 22:16:08 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2020-12-28 23:01:00 -0800
commitc715fb46c2d8eab48323a6008c5dbca550ebe2e0 (patch)
tree0f3edfd82629a620f08dd4e05f4f979f13648275 /lib/irb/color.rb
parent1ffb267c5c782ea15d01beb90d031274ca88cd8e (diff)
downloadruby-c715fb46c2d8eab48323a6008c5dbca550ebe2e0.tar.gz
[ruby/irb] Enhance colored inspect output
https://github.com/ruby/irb/commit/dffcdb5269
Diffstat (limited to 'lib/irb/color.rb')
-rw-r--r--lib/irb/color.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index 0f49291d85..56f5c4c625 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -107,7 +107,7 @@ module IRB # :nodoc:
# If `complete` is false (code is incomplete), this does not warn compile_error.
# This option is needed to avoid warning a user when the compile_error is happening
# because the input is not wrong but just incomplete.
- def colorize_code(code, complete: true)
+ def colorize_code(code, complete: true, ignore_error: false)
return code unless colorable?
symbol_state = SymbolState.new
@@ -118,7 +118,7 @@ module IRB # :nodoc:
in_symbol = symbol_state.scan_token(token)
str.each_line do |line|
line = Reline::Unicode.escape_for_print(line)
- if seq = dispatch_seq(token, expr, line, in_symbol: in_symbol)
+ if seq = dispatch_seq(token, expr, line, in_symbol: in_symbol, ignore_error: ignore_error)
colored << seq.map { |s| "\e[#{s}m" }.join('')
colored << line.sub(/\Z/, clear)
else
@@ -183,9 +183,9 @@ module IRB # :nodoc:
$VERBOSE = verbose
end
- def dispatch_seq(token, expr, str, in_symbol:)
+ def dispatch_seq(token, expr, str, in_symbol:, ignore_error:)
if token == :on_parse_error or token == :compile_error
- TOKEN_SEQ_EXPRS[token][0]
+ ignore_error ? nil : TOKEN_SEQ_EXPRS[token][0]
elsif in_symbol
[YELLOW]
elsif TOKEN_KEYWORDS.fetch(token, []).include?(str)