summaryrefslogtreecommitdiff
path: root/lib/pry
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pry')
-rw-r--r--lib/pry/config.rb27
-rw-r--r--lib/pry/control_d_handler.rb7
-rw-r--r--lib/pry/pry_instance.rb2
3 files changed, 32 insertions, 4 deletions
diff --git a/lib/pry/config.rb b/lib/pry/config.rb
index 55718200..2ed3542a 100644
--- a/lib/pry/config.rb
+++ b/lib/pry/config.rb
@@ -261,6 +261,33 @@ class Pry
@custom_attrs = @custom_attrs.dup
end
+ def control_d_handler=(value)
+ proxy_proc =
+ if value.arity == 2
+ Pry::Warning.warn(
+ "control_d_handler's arity of 2 parameters was deprecated. Now it " \
+ 'gets passed just 1 parameter (pry_instance). Please update your ' \
+ 'handler'
+ )
+ proc do |*args|
+ if args.size == 2
+ value.call(args.first, args[1])
+ else
+ value.call(args.first.eval_string, args.first)
+ end
+ end
+ else
+ proc do |*args|
+ if args.size == 2
+ value.call(args[1])
+ else
+ value.call(args.first)
+ end
+ end
+ end
+ @control_d_handler = proxy_proc
+ end
+
private
def lazy_readline
diff --git a/lib/pry/control_d_handler.rb b/lib/pry/control_d_handler.rb
index 1021c767..f9b93003 100644
--- a/lib/pry/control_d_handler.rb
+++ b/lib/pry/control_d_handler.rb
@@ -7,9 +7,10 @@ class Pry
# 1. In an expression behave like `!` command.
# 2. At top-level session behave like `exit` command.
# 3. In a nested session behave like `cd ..`.
- def self.default(eval_string, pry_instance)
- if !eval_string.empty?
- eval_string.replace('') # Clear input buffer.
+ def self.default(pry_instance)
+ if !pry_instance.eval_string.empty?
+ # Clear input buffer.
+ pry_instance.eval_string = ''
elsif pry_instance.binding_stack.one?
pry_instance.binding_stack.clear
throw(:breakout)
diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb
index 2aebedc2..41eddb78 100644
--- a/lib/pry/pry_instance.rb
+++ b/lib/pry/pry_instance.rb
@@ -595,7 +595,7 @@ class Pry
def handle_line(line, options)
if line.nil?
- config.control_d_handler.call(@eval_string, self)
+ config.control_d_handler.call(self)
return
end