aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb/color_printer.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2021-03-19 19:08:39 -0700
committergit <svn-admin@ruby-lang.org>2021-03-20 20:25:32 +0900
commit278522f0535d081ff6473f210cb45f923ff8810a (patch)
tree80ac90fdfc35677accc8906665ad66b3f219549c /lib/irb/color_printer.rb
parente019dd24df4ed7063ad80d4c2e4070141793f598 (diff)
downloadruby-278522f0535d081ff6473f210cb45f923ff8810a.tar.gz
[ruby/irb] Don't call Ruby 2.4+'s String#pretty_print
https://github.com/ruby/irb/commit/89bcf107be
Diffstat (limited to 'lib/irb/color_printer.rb')
-rw-r--r--lib/irb/color_printer.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/irb/color_printer.rb b/lib/irb/color_printer.rb
index 92afea51cd..30c6825750 100644
--- a/lib/irb/color_printer.rb
+++ b/lib/irb/color_printer.rb
@@ -21,6 +21,15 @@ module IRB
end
end
+ def pp(obj)
+ if obj.is_a?(String)
+ # Avoid calling Ruby 2.4+ String#pretty_print that splits a string by "\n"
+ text(obj.inspect)
+ else
+ super
+ end
+ end
+
def text(str, width = nil)
unless str.is_a?(String)
str = str.inspect