From a3d596a3196fffcdda686f413553a6aad7926f1a Mon Sep 17 00:00:00 2001 From: tompng Date: Thu, 16 Jan 2025 00:38:16 +0900 Subject: [PATCH] Colorize backref token bold green like global variables --- lib/irb/color.rb | 1 + test/irb/test_color.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/irb/color.rb b/lib/irb/color.rb index fca942b28..a7e311087 100644 --- a/lib/irb/color.rb +++ b/lib/irb/color.rb @@ -41,6 +41,7 @@ module Color on_embvar: [[RED], ALL], on_float: [[MAGENTA, BOLD], ALL], on_gvar: [[GREEN, BOLD], ALL], + on_backref: [[GREEN, BOLD], ALL], on_heredoc_beg: [[RED], ALL], on_heredoc_end: [[RED], ALL], on_ident: [[BLUE, BOLD], Ripper::EXPR_ENDFN], diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb index 9d78f5233..5529e2904 100644 --- a/test/irb/test_color.rb +++ b/test/irb/test_color.rb @@ -102,6 +102,7 @@ def test_colorize_code "\t" => Reline::Unicode.escape_for_print("\t") == ' ' ? ' ' : "\t", # not ^I "foo(*%W(bar))" => "foo(*#{RED}#{BOLD}%W(#{CLEAR}#{RED}bar#{CLEAR}#{RED}#{BOLD})#{CLEAR})", "$stdout" => "#{GREEN}#{BOLD}$stdout#{CLEAR}", + "$&" => "#{GREEN}#{BOLD}$&#{CLEAR}", "__END__" => "#{GREEN}__END__#{CLEAR}", "foo\n__END__\nbar" => "foo\n#{GREEN}__END__#{CLEAR}\nbar", "foo\n< "foo\n#{RED}< "[#{BLUE}#{BOLD}1#{CLEAR}]#{RED}#{REVERSE}]#{CLEAR}]^S", "def req(true) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}true#{CLEAR}) end", "nil = 1" => "#{CYAN}#{BOLD}nil#{CLEAR} = #{BLUE}#{BOLD}1#{CLEAR}", - "alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} $1", + "alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} #{GREEN}#{BOLD}$1#{CLEAR}", "class bad; end" => "#{GREEN}class#{CLEAR} bad; #{GREEN}end#{CLEAR}", "def req(@a) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(@a) #{GREEN}end#{CLEAR}", })