Sha256: 0960f644e579aab52c1e7fd95321e97d8b2430db14cd1a0d8840af8c00bf60d7

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

require "byebug/command"
require "byebug/helpers/parse"

module Byebug
  #
  # Allows the user to continue execution until the next breakpoint, as
  # long as it is different from the current one
  #
  class SkipCommand < Command
    include Helpers::ParseHelper

    class << self
      attr_writer :file_line, :file_path
      attr_reader :previous_autolist

      def file_line
        @file_line ||= 0
      end

      def file_path
        @file_path ||= ""
      end

      def setup_autolist(value)
        @previous_autolist = ListCommand.always_run
        ListCommand.always_run = value
      end

      def restore_autolist
        ListCommand.always_run = @previous_autolist
        @previous_autolist = nil
      end
    end

    def self.regexp
      /^\s* sk(?:ip)? \s*$/x
    end

    def self.description
      <<-DESCRIPTION
        sk[ip]

        #{short_description}
      DESCRIPTION
    end

    def self.short_description
      "Runs until the next breakpoint as long as it is different from the current one"
    end

    def initialize_attributes
      self.class.always_run = 2
      self.class.setup_autolist(0)
      self.class.file_path = frame.file
      self.class.file_line = frame.line
    end

    def keep_execution
      [self.class.file_path, self.class.file_line] == [frame.file, frame.line]
    end

    def reset_attributes
      self.class.always_run = 0
      ListCommand.new(processor).execute if self.class.previous_autolist == 1
      self.class.restore_autolist
    end

    def auto_run
      return false unless self.class.always_run == 2

      keep_execution ? processor.proceed! : reset_attributes
      true
    end

    def execute
      return if auto_run

      initialize_attributes
      processor.proceed!
      Byebug.stop if Byebug.stoppable?
    end
  end
end

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/byebug-11.0.1/lib/byebug/commands/skip.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/byebug-11.0.1/lib/byebug/commands/skip.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/byebug-11.0.1/lib/byebug/commands/skip.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/byebug-11.0.1/lib/byebug/commands/skip.rb
byebug-11.0.1 lib/byebug/commands/skip.rb