Firstly wrap the entire completion_proc in a begin/rescue/end so that
even if something we're not expecting goes wrong, we don't fail.
Secondly, only throw the user out of pry if reading from readline fails
five times in a row. This avoids a transient error (like a time-out, or
a failed tab completion) from kicking you out of pry; but also avoids
the infinite looping problem that can happen if the error is not transient.
The commits in this branch would conflict with the current ones in the master
branch. I've modified the code of pry/completion.rb so that instead of escaping
*all* input it will only escape it when this hasn't already been done so.
This fixes#601.
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
Jruby doesn't always provide the method `#instance_methods()` on objects. By
checking to see if this method exists before using it the completion system
won't totally barf itself when used on Jruby.
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
Pry is now able to complete variable names for instance and class variables, as
well as being able to complete methods and the like on these variables.
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
User input should be escaped using Regexp.escape() before trying to figure out
what data to use for the Readline completion system. Not escaping this input
would cause Pry to fail for input such as `[10, 20].map(&:class)`.
This problem was caused due to lib/completion.rb converting the input (in this
case it would be ":class)") to a Regexp object. Because this, when converted to
a Regexp object, is invalid it would cause Pry to throw a RegexpError error and
bail out.
See #601 for more information.
Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>