summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Cheek <josh.cheek@gmail.com>2019-07-11 08:54:10 -0500
committerKyrylo Silin <silin@kyrylo.org>2019-07-11 16:54:10 +0300
commit846b7ecb6f804d4192cc44a673c2a85b73f1f0b7 (patch)
tree18a393e9e709f4077001455b2e95c22c6ae945a3 /lib
parent028af11c0e530398060e0a3e2194140590ec3c7c (diff)
downloadpry-846b7ecb6f804d4192cc44a673c2a85b73f1f0b7.tar.gz
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 :)
Diffstat (limited to 'lib')
-rw-r--r--lib/pry/command.rb2
-rw-r--r--lib/pry/testable/pry_tester.rb10
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/pry/command.rb b/lib/pry/command.rb
index 99bde110..4e213f39 100644
--- a/lib/pry/command.rb
+++ b/lib/pry/command.rb
@@ -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)
diff --git a/lib/pry/testable/pry_tester.rb b/lib/pry/testable/pry_tester.rb
index 55f0b558..2bd9b875 100644
--- a/lib/pry/testable/pry_tester.rb
+++ b/lib/pry/testable/pry_tester.rb
@@ -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