mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
No longer touching the the input. It's a global lock for now (:all)
This commit is contained in:
parent
7d592fead5
commit
ec2918db89
2 changed files with 14 additions and 26 deletions
|
@ -120,7 +120,9 @@ class Pry
|
||||||
# Note that there can be some inefficiency, as we could immediately
|
# Note that there can be some inefficiency, as we could immediately
|
||||||
# succeed in enter_interruptible_region(), even before the one requesting
|
# succeed in enter_interruptible_region(), even before the one requesting
|
||||||
# the ownership has the chance to register itself as an owner.
|
# the ownership has the chance to register itself as an owner.
|
||||||
|
# To mitigate the issue, we sleep a little bit.
|
||||||
leave_interruptible_region
|
leave_interruptible_region
|
||||||
|
sleep 0.01
|
||||||
retry
|
retry
|
||||||
|
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -22,7 +22,6 @@ class Pry
|
||||||
def initialize(pry, options = {})
|
def initialize(pry, options = {})
|
||||||
@pry = pry
|
@pry = pry
|
||||||
@indent = Pry::Indent.new
|
@indent = Pry::Indent.new
|
||||||
@should_try_next_input = true
|
|
||||||
|
|
||||||
if options[:target]
|
if options[:target]
|
||||||
@pry.push_binding options[:target]
|
@pry.push_binding options[:target]
|
||||||
|
@ -36,30 +35,13 @@ class Pry
|
||||||
# thrown with it.
|
# thrown with it.
|
||||||
def start
|
def start
|
||||||
prologue
|
prologue
|
||||||
while should_try_next_input?
|
Pry::InputLock.for(:all).with_ownership { repl }
|
||||||
use_next_input
|
|
||||||
Pry::InputLock.for(input).with_ownership { repl }
|
|
||||||
end
|
|
||||||
ensure
|
ensure
|
||||||
epilogue
|
epilogue
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Should try next input?
|
|
||||||
# @return [bool]
|
|
||||||
def should_try_next_input?
|
|
||||||
@should_try_next_input
|
|
||||||
end
|
|
||||||
|
|
||||||
# Cycle through the inputs
|
|
||||||
# Currently just get the config default input, the first one being the
|
|
||||||
# command line one.
|
|
||||||
def use_next_input
|
|
||||||
pry.input = Pry.config.input
|
|
||||||
@should_try_next_input = false
|
|
||||||
end
|
|
||||||
|
|
||||||
# Set up the repl session.
|
# Set up the repl session.
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def prologue
|
def prologue
|
||||||
|
@ -88,11 +70,7 @@ class Pry
|
||||||
output.puts ""
|
output.puts ""
|
||||||
pry.reset_eval_string
|
pry.reset_eval_string
|
||||||
when :no_more_input
|
when :no_more_input
|
||||||
unless should_try_next_input?
|
output.puts "" if output.tty?
|
||||||
output.puts "Error: Pry ran out of things to read from! " \
|
|
||||||
"Attempting to break out of REPL."
|
|
||||||
output.puts "" if output.tty?
|
|
||||||
end
|
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
output.puts "" if val.nil? && output.tty?
|
output.puts "" if val.nil? && output.tty?
|
||||||
|
@ -144,12 +122,20 @@ class Pry
|
||||||
# @return [Object] Whatever the given block returns.
|
# @return [Object] Whatever the given block returns.
|
||||||
# @return [:no_more_input] Indicates that no more input can be read.
|
# @return [:no_more_input] Indicates that no more input can be read.
|
||||||
def handle_read_errors
|
def handle_read_errors
|
||||||
|
should_retry = true
|
||||||
exception_count = 0
|
exception_count = 0
|
||||||
|
|
||||||
begin
|
begin
|
||||||
yield
|
yield
|
||||||
rescue EOFError
|
rescue EOFError
|
||||||
return :no_more_input
|
pry.input = Pry.config.input
|
||||||
|
if !should_retry
|
||||||
|
output.puts "Error: Pry ran out of things to read from! " \
|
||||||
|
"Attempting to break out of REPL."
|
||||||
|
return :no_more_input
|
||||||
|
end
|
||||||
|
should_retry = false
|
||||||
|
retry
|
||||||
|
|
||||||
# Handle <Ctrl+C> like Bash: empty the current input buffer, but don't
|
# Handle <Ctrl+C> like Bash: empty the current input buffer, but don't
|
||||||
# quit. This is only for MRI 1.9; other versions of Ruby don't let you
|
# quit. This is only for MRI 1.9; other versions of Ruby don't let you
|
||||||
|
@ -211,7 +197,7 @@ class Pry
|
||||||
end
|
end
|
||||||
|
|
||||||
def input_readline(*args)
|
def input_readline(*args)
|
||||||
Pry::InputLock.for(input).interruptible_region do
|
Pry::InputLock.for(:all).interruptible_region do
|
||||||
input.readline(*args)
|
input.readline(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue