mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Attempt to allow pasting multiple lines with leading dots (#2060)
Two tests are breaking, and I kind of understand why, but I'm not sure what to do about it. Figured I should commit and send a PR in hopes of another brain being able to help me out :)
This commit is contained in:
parent
028af11c0e
commit
846b7ecb6f
4 changed files with 14 additions and 6 deletions
|
@ -166,7 +166,7 @@ class Pry
|
|||
prefix = convert_to_regex(Pry.config.command_prefix)
|
||||
prefix = "(?:#{prefix})?" unless options[:use_prefix]
|
||||
|
||||
/^#{prefix}#{convert_to_regex(match)}(?!\S)/
|
||||
/\A#{prefix}#{convert_to_regex(match)}(?!\S)/
|
||||
end
|
||||
|
||||
def convert_to_regex(obj)
|
||||
|
|
|
@ -29,7 +29,15 @@ class Pry
|
|||
if @pry.process_command(str)
|
||||
last_command_result_or_output
|
||||
else
|
||||
@pry.evaluate_ruby(str)
|
||||
# Check if this is a multiline paste.
|
||||
begin
|
||||
complete_expr = Pry::Code.complete_expression?(str)
|
||||
rescue SyntaxError => exception
|
||||
@pry.output.puts(
|
||||
"SyntaxError: #{exception.message.sub(/.*syntax error, */m, '')}"
|
||||
)
|
||||
end
|
||||
@pry.evaluate_ruby(str) if complete_expr
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -456,7 +456,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(commands: klass).eval("def yo\nhello\n")).to eq 7
|
||||
expect(pry_tester(commands: klass).eval("def yo", "hello")).to eq 7
|
||||
end
|
||||
|
||||
it(
|
||||
|
@ -469,7 +469,7 @@ describe "commands" do
|
|||
end
|
||||
end
|
||||
|
||||
expect(pry_tester(commands: klass).eval("def yo\nhello\n")).to eq 5
|
||||
expect(pry_tester(commands: klass).eval("def yo", "hello\n")).to eq 5
|
||||
end
|
||||
|
||||
it 'should set the commands default, and the default should be overridable' do
|
||||
|
|
|
@ -342,7 +342,7 @@ RSpec.describe Pry::Command do
|
|||
before { subject.command_options(use_prefix: true) }
|
||||
|
||||
it "returns a Regexp without a prefix" do
|
||||
expect(subject.command_regex).to eq(/^test\-command(?!\S)/)
|
||||
expect(subject.command_regex).to eq(/\Atest\-command(?!\S)/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -350,7 +350,7 @@ RSpec.describe Pry::Command do
|
|||
before { subject.command_options(use_prefix: false) }
|
||||
|
||||
it "returns a Regexp with a prefix" do
|
||||
expect(subject.command_regex).to eq(/^(?:)?test\-command(?!\S)/)
|
||||
expect(subject.command_regex).to eq(/\A(?:)?test\-command(?!\S)/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue