Sha256: 46037bd2d545d55f9cc6ebb16a313e7ca48fb6d4aa84e5f9082509a8a4823717

Contents?: true

Size: 964 Bytes

Versions: 6508

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

class Pry
  # @api private
  # @since v0.13.0
  module ControlDHandler
    # Deal with the ^D key being pressed. Different behaviour in different
    # cases:
    #   1. In an expression behave like `!` command.
    #   2. At top-level session behave like `exit` command.
    #   3. In a nested session behave like `cd ..`.
    def self.default(pry_instance)
      if !pry_instance.eval_string.empty?
        # Clear input buffer.
        pry_instance.eval_string = ''
      elsif pry_instance.binding_stack.one?
        pry_instance.binding_stack.clear
        throw(:breakout)
      else
        # Otherwise, saves current binding stack as old stack and pops last
        # binding out of binding stack (the old stack still has that binding).
        cd_state = Pry::CommandState.default.state_for('cd')
        cd_state.old_stack = pry_instance.binding_stack.dup
        pry_instance.binding_stack.pop
      end
    end
  end
end

Version data entries

6,508 entries across 6,504 versions & 30 rubygems

Version Path
affixapi-1.1.102 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/pry-0.13.1/lib/pry/control_d_handler.rb
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb
cybrid_api_organization_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/pry-0.14.2/lib/pry/control_d_handler.rb