File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ class PryBackend
57
57
58
58
def initialize
59
59
require 'pry'
60
- Pry . memory_size = 3
60
+ Pry . memory_size = 3
61
61
Pry . pager = false # Don't use the pager
62
62
Pry . print = proc { |output , value |} # No result printing
63
63
Pry . exception_handler = proc { |output , exception , _ | }
@@ -72,11 +72,21 @@ def eval(code, store_history)
72
72
reset
73
73
raise SystemExit
74
74
end
75
- unless @pry . eval_string . empty?
75
+
76
+ # Pry::Code.complete_expression? return false
77
+ if !@pry . eval_string . empty?
76
78
syntax_error = @pry . eval_string
77
79
@pry . reset_eval_string
78
- @pry . evaluate_ruby syntax_error
80
+ @pry . evaluate_ruby ( syntax_error )
81
+
82
+ # Pry::Code.complete_expression? raise SyntaxError
83
+ # evaluate again for current line number
84
+ elsif @pry . last_result_is_exception? &&
85
+ @pry . last_exception . is_a? ( SyntaxError ) &&
86
+ @pry . last_exception . is_a? ( Pry ::UserError )
87
+ @pry . evaluate_ruby ( code )
79
88
end
89
+
80
90
raise @pry . last_exception if @pry . last_result_is_exception?
81
91
@pry . push_initial_binding unless @pry . current_binding # ensure that we have a binding
82
92
@pry . last_result
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ def execute_request(msg)
112
112
113
113
def error_content ( e )
114
114
rindex = e . backtrace . rindex { |line | line . start_with? ( @backend . eval_path ) } || -1
115
- backtrace = e . backtrace [ 0 ..rindex ]
115
+ backtrace = SyntaxError === e && rindex == - 1 ? [ ] : e . backtrace [ 0 ..rindex ]
116
116
{ ename : e . class . to_s ,
117
117
evalue : e . message ,
118
118
traceback : [ "#{ RED } #{ e . class } #{ RESET } : #{ e . message } " , *backtrace ] }
You can’t perform that action at this time.
0 commit comments