From fcd9bc28e3d7d301bcdf6eea8ffa25c0c3ec184f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 10 Nov 2019 13:54:44 -0800 Subject: [PATCH] qsymbols and symbols should be colored as Symbol --- lib/irb/color.rb | 2 +- test/irb/test_color.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/irb/color.rb b/lib/irb/color.rb index 92bbd9ebd5..3ce628ff24 100644 --- a/lib/irb/color.rb +++ b/lib/irb/color.rb @@ -205,7 +205,7 @@ module IRB # :nodoc: def scan_token(token) prev_state = @stack.last case token - when :on_symbeg + when :on_symbeg, :on_symbols_beg, :on_qsymbols_beg @stack << true when :on_ident, :on_op, :on_const, :on_ivar, :on_cvar, :on_gvar, :on_kw if @stack.last # Pop only when it's Symbol diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb index 6446c0ad23..3ced640004 100644 --- a/test/irb/test_color.rb +++ b/test/irb/test_color.rb @@ -43,8 +43,8 @@ module TestIRB "%w[a b]" => "#{RED}#{BOLD}%w[#{CLEAR}#{RED}a#{CLEAR} #{RED}b#{CLEAR}#{RED}#{BOLD}]#{CLEAR}", "%W[a b]" => "#{RED}#{BOLD}%W[#{CLEAR}#{RED}a#{CLEAR} #{RED}b#{CLEAR}#{RED}#{BOLD}]#{CLEAR}", "%s[a b]" => "#{YELLOW}%s[#{CLEAR}#{YELLOW}a b#{CLEAR}#{YELLOW}]#{CLEAR}", - "%i[c d]" => "#{RED}#{BOLD}%i[#{CLEAR}#{RED}c#{CLEAR} #{RED}d#{CLEAR}#{RED}#{BOLD}]#{CLEAR}", - "%I[c d]" => "#{RED}#{BOLD}%I[#{CLEAR}#{RED}c#{CLEAR} #{RED}d#{CLEAR}#{RED}#{BOLD}]#{CLEAR}", + "%i[c d]" => "#{YELLOW}%i[#{CLEAR}#{YELLOW}c#{CLEAR}#{YELLOW} #{CLEAR}#{YELLOW}d#{CLEAR}#{YELLOW}]#{CLEAR}", + "%I[c d]" => "#{YELLOW}%I[#{CLEAR}#{YELLOW}c#{CLEAR}#{YELLOW} #{CLEAR}#{YELLOW}d#{CLEAR}#{YELLOW}]#{CLEAR}", "{'a': 1}" => "{#{RED}#{BOLD}'#{CLEAR}#{RED}a#{CLEAR}#{RED}#{BOLD}':#{CLEAR} #{BLUE}#{BOLD}1#{CLEAR}}", ":Struct" => "#{YELLOW}:#{CLEAR}#{YELLOW}Struct#{CLEAR}", '"#{}"' => "#{RED}#{BOLD}\"#{CLEAR}#{RED}\#{#{CLEAR}#{RED}}#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}", @@ -61,7 +61,7 @@ module TestIRB 'URI.parse "#{}"' => "#{BLUE}#{BOLD}#{UNDERLINE}URI#{CLEAR}.parse #{RED}#{BOLD}\"#{CLEAR}#{RED}\#{#{CLEAR}#{RED}}#{CLEAR}#{RED}#{BOLD}\"#{CLEAR}", "begin\nrescue\nend" => "#{GREEN}begin#{CLEAR}\n#{GREEN}rescue#{CLEAR}\n#{GREEN}end#{CLEAR}", "foo %w[bar]" => "foo #{RED}#{BOLD}%w[#{CLEAR}#{RED}bar#{CLEAR}#{RED}#{BOLD}]#{CLEAR}", - "foo %i[bar]" => "foo #{RED}#{BOLD}%i[#{CLEAR}#{RED}bar#{CLEAR}#{RED}#{BOLD}]#{CLEAR}", + "foo %i[bar]" => "foo #{YELLOW}%i[#{CLEAR}#{YELLOW}bar#{CLEAR}#{YELLOW}]#{CLEAR}", "foo :@bar, baz, :@@qux, :$quux" => "foo #{YELLOW}:#{CLEAR}#{YELLOW}@bar#{CLEAR}, baz, #{YELLOW}:#{CLEAR}#{YELLOW}@@qux#{CLEAR}, #{YELLOW}:#{CLEAR}#{YELLOW}$quux#{CLEAR}", "`echo`" => "#{RED}#{BOLD}`#{CLEAR}#{RED}echo#{CLEAR}#{RED}#{BOLD}`#{CLEAR}", "\t" => "\t", # not ^I