def run(initial = true, &block)
      return_value = nil
      command = catch(:breakout_nav) do  # Throws from PryDebugger::Commands
        return_value = yield
        {}    # Nothing thrown == no navigational command
      end

      times = (command[:times] || 1).to_i   # Command argument
      times = 1 if times <= 0

      if [:step, :next, :finish].include? command[:action]
        @pry = command[:pry]   # Pry instance to resume after stepping
        Debugger.start unless Debugger.started?

        if initial
          # Movement when on the initial binding.pry line will have a frame
          # inside Debugger. If we step normally, it'll stop inside this
          # Processor. So jump out and stop at the above frame, then step/next
          # from our callback.
          Debugger.current_context.stop_frame = 1
          @delayed[command[:action]] = times

        elsif :next == command[:action]
          step_over times

        elsif :step == command[:action]
          step times

        elsif :finish == command[:action]
          finish
        end
      else
        stop
      end

      return_value
    end
def run(initial = true, &block)
      return_value = nil
      command = catch(:breakout_nav) do  # Throws from PryDebugger::Commands
        return_value = yield
        {}    # Nothing thrown == no navigational command
      end

      times = (command[:times] || 1).to_i   # Command argument
      times = 1 if times <= 0

      if [:step, :next, :finish].include? command[:action]
        @pry = command[:pry]   # Pry instance to resume after stepping
        Debugger.start unless Debugger.started?

        if initial
          # Movement when on the initial binding.pry line will have a frame
          # inside Debugger. If we step normally, it'll stop inside this
          # Processor. So jump out and stop at the above frame, then step/next
          # from our callback.
          Debugger.current_context.stop_frame = 1
          @delayed[command[:action]] = times

        elsif :next == command[:action]
          step_over times

        elsif :step == command[:action]
          step times

        elsif :finish == command[:action]
          finish
        end
      else
        stop
      end

      return_value
    end
Wrap a Pry REPL to catch navigational commands and act on them.