Manually merged branch "issue/601".

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>
This commit is contained in:
Yorick Peterse 2012-06-19 15:47:52 +02:00
commit 3fa74ea862
2 changed files with 9 additions and 1 deletions

View File

@ -74,8 +74,9 @@ class Pry
when /^(:[^:.]*)$/
# Symbol
if Symbol.respond_to?(:all_symbols)
sym = $1
sym = Regexp.quote($1)
candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
candidates.grep(/^#{sym}/)
else
[]

View File

@ -23,6 +23,13 @@ describe Pry::InputCompleter do
end
end
it 'should take parenthesis and other characters into account for symbols' do
b = Pry.binding_for(Object.new)
completer = Pry::InputCompleter.build_completion_proc(b)
lambda { completer.call(":class)") }.should.not.raise(RegexpError)
end
it 'should complete instance variables' do
object = Object.new