aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-29 13:34:19 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-29 13:34:19 +0900
commit068d327595814a3448290eeba897fc37a8bb2dfb (patch)
tree323bdd2fbd30efbc437bb35dbc62ace81db94232
parentcc66272e5061020cac6864bbc2f68f7d327ecfbb (diff)
downloadruby-068d327595814a3448290eeba897fc37a8bb2dfb.tar.gz
Colorize compile_error as same as on_parse_error
-rw-r--r--lib/irb/color.rb5
-rw-r--r--test/irb/test_color.rb2
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index b53cc75035..b1f7c21743 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -56,7 +56,7 @@ module IRB # :nodoc:
on_tstring_content: [[RED], ALL],
on_tstring_end: [[RED], ALL],
on_words_beg: [[RED], ALL],
- on_parse_error: [[RED, REVERSE], ALL],
+ ERROR: [[RED, REVERSE], ALL],
}
rescue NameError
# Give up highlighting Ripper-incompatible older Ruby
@@ -67,7 +67,8 @@ module IRB # :nodoc:
class Lexer < Ripper::Lexer
if method_defined?(:token)
def on_error(mesg)
- @buf.push Elem.new([lineno(), column()], __callee__, token(), state())
+ # :ERROR comes before other :on_ symbols
+ @buf.push Elem.new([lineno(), column()], :ERROR, token(), state())
end
alias on_parse_error on_error
alias compile_error on_error
diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb
index 8059b81430..edca2d7050 100644
--- a/test/irb/test_color.rb
+++ b/test/irb/test_color.rb
@@ -40,7 +40,7 @@ module TestIRB
"'a\nb'" => "#{RED}'#{CLEAR}#{RED}a#{CLEAR}\n#{RED}b#{CLEAR}#{RED}'#{CLEAR}",
"4.5.6" => "#{MAGENTA}#{BOLD}4.5#{CLEAR}#{RED}#{REVERSE}.6#{CLEAR}",
"[1]]]" => "[1]]]",
- "\e[0m\n" => "^[[#{BLUE}#{BOLD}0#{CLEAR}m\n",
+ "\e[0m\n" => "#{RED}#{REVERSE}^[#{CLEAR}[#{BLUE}#{BOLD}0#{CLEAR}m\n",
"%w[a b]" => "#{RED}%w[#{CLEAR}#{RED}a#{CLEAR} #{RED}b#{CLEAR}#{RED}]#{CLEAR}",
"%i[c d]" => "#{RED}%i[#{CLEAR}#{RED}c#{CLEAR} #{RED}d#{CLEAR}#{RED}]#{CLEAR}",
"{'a': 1}" => "{#{RED}'#{CLEAR}#{RED}a#{CLEAR}#{RED}':#{CLEAR} #{BLUE}#{BOLD}1#{CLEAR}}",