summaryrefslogtreecommitdiff
path: root/lib/irb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2019-05-25 07:48:58 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2019-05-25 07:49:15 -0700
commitada64aa9e7f1e087b9fd536d9bc512de401f42a0 (patch)
tree083d5c1b46c0a009519dc70c248f0cef267cdd8b /lib/irb
parent7c507345a73afe3f599e407e851b9c0d708adeb0 (diff)
Clear IRB::Color escape sequence before newline
because otherwise prompt and other things could be polluted.
Diffstat (limited to 'lib/irb')
-rw-r--r--lib/irb/color.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index 8cee483261..ad5b203010 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -82,7 +82,7 @@ module IRB # :nodoc:
Ripper.lex(code).each do |(_line, _col), token, str, expr|
if seq = dispatch_seq(token, expr, str)
Reline::Unicode.escape_for_print(str).each_line do |line|
- colored << "#{seq.map { |s| "\e[#{s}m" }.join('')}#{line}#{clear}"
+ colored << "#{seq.map { |s| "\e[#{s}m" }.join('')}#{line.sub(/\n?\z/, "#{clear}\\0")}"
end
else
colored << Reline::Unicode.escape_for_print(str)