You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1013 B
33 lines
1013 B
From ff6263fd9ddf2d689ecfa8fa7eb1216bfad441a8 Mon Sep 17 00:00:00 2001
|
|
From: Akira Matsuda <ronnie@dio.jp>
|
|
Date: Thu, 8 Dec 2016 03:51:38 +0900
|
|
Subject: [PATCH] Avoid calling Ruby 2.4+ String#pretty_print in ColorPrinter
|
|
|
|
Ruby 2.4+ defines String's own pretty_print that prints multiline Strings prettier
|
|
see: https://bugs.ruby-lang.org/issues/12664
|
|
|
|
fixes #1585
|
|
---
|
|
lib/pry/color_printer.rb | 8 +++++++-
|
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/lib/pry/color_printer.rb b/lib/pry/color_printer.rb
|
|
index 48bcc1a..ce52b8d 100644
|
|
--- a/lib/pry/color_printer.rb
|
|
+++ b/lib/pry/color_printer.rb
|
|
@@ -31,7 +31,13 @@ def text(str, width = str.length)
|
|
end
|
|
|
|
def pp(obj)
|
|
- super
|
|
+ if String === obj
|
|
+ # Avoid calling Ruby 2.4+ String#pretty_print that prints multiline
|
|
+ # Strings prettier
|
|
+ Object.instance_method(:pretty_print).bind(obj).call
|
|
+ else
|
|
+ super
|
|
+ end
|
|
rescue => e
|
|
raise if e.is_a? Pry::Pager::StopPaging
|
|
begin
|