summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mair <jrmair@gmail.com>2015-02-16 20:20:14 +0100
committerJohn Mair <jrmair@gmail.com>2015-02-16 20:20:22 +0100
commit1e71d84740c1aa51334185d732b60815b8f6fb2a (patch)
tree119735760099010903c907cf11377bb19587aa60
parent738c60da8e1c0b6b2c93c8928cb810b67227a867 (diff)
downloadpry-refactor/dont-throwaway-pry-instance.tar.gz
Use _pry_.pager if possiblerefactor/dont-throwaway-pry-instance
The prior code was always using Pry.new.pager -- this was weird for a few reasons: 1) _pry_ is always available (afaict) so why not just call _pry_.pager rather than creating a throway pry object for this? 2) When creating a new Pry instance (via Pry.new) the when_started hook is run...this resulted in some errors and strange behaviour since a naked instance created with Pry.new is not properly configured (it misses a 'target' (binding) I left the old code in there though to trigger when _pry_ is not available since I assume it's there for good reason?!
-rw-r--r--lib/pry/helpers/base_helpers.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/pry/helpers/base_helpers.rb b/lib/pry/helpers/base_helpers.rb
index 59c1342d..dd0ef1e9 100644
--- a/lib/pry/helpers/base_helpers.rb
+++ b/lib/pry/helpers/base_helpers.rb
@@ -106,7 +106,11 @@ class Pry
# enabled). Infers where to send the output if used as a mixin.
# DEPRECATED.
def stagger_output(text, out = nil)
- Pry.new.pager.page text
+ if _pry_
+ _pry_.pager.page text
+ else
+ Pry.new.pager.page text
+ end
end
end
end