From 068d327595814a3448290eeba897fc37a8bb2dfb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 29 May 2019 13:34:19 +0900 Subject: Colorize compile_error as same as on_parse_error --- lib/irb/color.rb | 5 +++-- test/irb/test_color.rb | 2 +- 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}}", -- cgit v1.2.3