Skip to content

Commit e5ad894

Browse files
tompngmatzbot
authored andcommitted
[ruby/irb] Colorize backref token bold green like global variables
(ruby/irb#1065) ruby/irb@0b60a5be1d
1 parent e02c749 commit e5ad894

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/irb/color.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module Color
4141
on_embvar: [[RED], ALL],
4242
on_float: [[MAGENTA, BOLD], ALL],
4343
on_gvar: [[GREEN, BOLD], ALL],
44+
on_backref: [[GREEN, BOLD], ALL],
4445
on_heredoc_beg: [[RED], ALL],
4546
on_heredoc_end: [[RED], ALL],
4647
on_ident: [[BLUE, BOLD], Ripper::EXPR_ENDFN],

test/irb/test_color.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def test_colorize_code
102102
"\t" => Reline::Unicode.escape_for_print("\t") == ' ' ? ' ' : "\t", # not ^I
103103
"foo(*%W(bar))" => "foo(*#{RED}#{BOLD}%W(#{CLEAR}#{RED}bar#{CLEAR}#{RED}#{BOLD})#{CLEAR})",
104104
"$stdout" => "#{GREEN}#{BOLD}$stdout#{CLEAR}",
105+
"$&" => "#{GREEN}#{BOLD}$&#{CLEAR}",
105106
"__END__" => "#{GREEN}__END__#{CLEAR}",
106107
"foo\n__END__\nbar" => "foo\n#{GREEN}__END__#{CLEAR}\nbar",
107108
"foo\n<<A\0\0bar\nA\nbaz" => "foo\n#{RED}<<A#{CLEAR}^@^@bar\n#{RED}A#{CLEAR}\nbaz",
@@ -136,7 +137,7 @@ def test_colorize_code
136137
"[1]]]\u0013" => "[#{BLUE}#{BOLD}1#{CLEAR}]#{RED}#{REVERSE}]#{CLEAR}]^S",
137138
"def req(true) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}true#{CLEAR}) end",
138139
"nil = 1" => "#{CYAN}#{BOLD}nil#{CLEAR} = #{BLUE}#{BOLD}1#{CLEAR}",
139-
"alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} $1",
140+
"alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} #{GREEN}#{BOLD}$1#{CLEAR}",
140141
"class bad; end" => "#{GREEN}class#{CLEAR} bad; #{GREEN}end#{CLEAR}",
141142
"def req(@a) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(@a) #{GREEN}end#{CLEAR}",
142143
})

0 commit comments

Comments
 (0)