File tree Expand file tree Collapse file tree 5 files changed +54
-3
lines changed Expand file tree Collapse file tree 5 files changed +54
-3
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/core"
4
+
5
+ module Byebug
6
+ #
7
+ # Extends the PryProcessor to make it work with Pry-Remote
8
+ #
9
+ class PryRemoteProcessor < PryProcessor
10
+ def self . start
11
+ super
12
+
13
+ Byebug . current_context . step_out ( 5 , true )
14
+ end
15
+
16
+ def resume_pry
17
+ new_binding = frame . _binding
18
+
19
+ run do
20
+ if defined? ( @pry ) && @pry
21
+ @pry . repl ( new_binding )
22
+ else
23
+ @pry = Pry . start_without_pry_byebug ( new_binding , input : input , output : output )
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def input
31
+ server . client . input_proxy
32
+ end
33
+
34
+ def output
35
+ server . client . output
36
+ end
37
+
38
+ def server
39
+ PryByebug . current_remote_server
40
+ end
41
+ end
42
+ end
Original file line number Diff line number Diff line change 7
7
#
8
8
module PryByebug
9
9
# Reference to currently running pry-remote server. Used by the processor.
10
- attr_accessor :current_remote_server
10
+ class << self
11
+ attr_accessor :current_remote_server
12
+ end
11
13
12
14
module_function
13
15
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class ExitAllCommand < Pry::Command::ExitAll
10
10
def process
11
11
super
12
12
ensure
13
+ PryByebug . current_remote_server &.teardown
13
14
Byebug . stop if Byebug . stoppable?
14
15
end
15
16
end
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class FinishCommand < Pry::ClassCommand
18
18
BANNER
19
19
20
20
def process
21
+ PryByebug . current_remote_server &.teardown
21
22
PryByebug . check_file_context ( target )
22
23
23
24
breakout_navigation :finish
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
require "byebug/processors/pry_processor"
4
+ require "byebug/processors/pry_remote_processor"
4
5
5
6
class << Pry ::REPL
6
7
alias start_without_pry_byebug start
7
8
8
9
def start_with_pry_byebug ( options = { } )
9
10
target = options [ :target ]
10
11
11
- if target . is_a? ( Binding ) && PryByebug . file_context? ( target )
12
- Byebug ::PryProcessor . start unless ENV [ "DISABLE_PRY" ]
12
+ if target . is_a? ( Binding ) && PryByebug . file_context? ( target ) && ! ENV [ "DISABLE_PRY" ]
13
+ run_remote? ? Byebug ::PryRemoteProcessor . start : Byebug :: PryProcessor . start
13
14
else
14
15
# No need for the tracer unless we have a file context to step through
15
16
start_without_pry_byebug ( options )
16
17
end
17
18
end
18
19
20
+ def run_remote?
21
+ PryByebug . current_remote_server
22
+ end
23
+
19
24
alias start start_with_pry_byebug
20
25
end
You can’t perform that action at this time.
0 commit comments