ruby-changes:55901
From: Nobuyoshi <ko1@a...>
Date: Wed, 29 May 2019 13:37:56 +0900 (JST)
Subject: [ruby-changes:55901] Nobuyoshi Nakada: 068d327595 (trunk): Colorize compile_error as same as on_parse_error
https://git.ruby-lang.org/ruby.git/commit/?id=068d327595 From 068d327595814a3448290eeba897fc37a8bb2dfb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 29 May 2019 13:34:19 +0900 Subject: Colorize compile_error as same as on_parse_error diff --git a/lib/irb/color.rb b/lib/irb/color.rb index b53cc75..b1f7c21 100644 --- a/lib/irb/color.rb +++ b/lib/irb/color.rb @@ -56,7 +56,7 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L56 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: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L67 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 8059b81..edca2d7 100644 --- a/test/irb/test_color.rb +++ b/test/irb/test_color.rb @@ -40,7 +40,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L40 "'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 v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/