Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignore_empty_commands setting. #773

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Dec 12, 2020

  1. Add ignore_empty_commands setting.

    Add the `ignore_empty_commands` boolean setting. It defaults to false, which causes an empty command to repeat the last command (the current behavior). If true, an empty command is a no-op.
    
    I want this setting because I frequently press enter a few times in my Rails server terminal (to put a vertical space in the log entries printed to stdout) and then later I try to debug some code in the server. When the debugger line is executed, ByeBug reads those newlines and runs the last command (often continue).
    
    Fixes deivid-rodriguez#700
    
    # Demo
    
    ## When the setting is false
    
    ```
    $ cat ~/.byebugrc
    set histfile /home/gabrielx/byebug.history
    #set ignore_empty_commands true
    $
    $ bundle exec ./test.rb
    
    [3, 12] in /home/gabrielx/projects/byebug/test.rb
        3:
        4: require 'byebug'
        5:
        6: debugger
        7:
    =>  8: sleep 2.1
        9: debugger
       10:
       11: sleep 2.2
       12: debugger
    (byebug) c
    
    [3, 12] in /home/gabrielx/projects/byebug/test.rb
        3:
        4: require 'byebug'
        5:
        6: debugger
        7:
        8: sleep 2.1
        9: debugger
       10:
    => 11: sleep 2.2
       12: debugger
    (byebug)
    
    [21, 30] in /home/gabrielx/.rvm/gems/ruby-2.5.3/gems/bundler-2.2.0.rc.2/lib/bundler/cli.rb
       21:     }.freeze
       22:
       23:     def self.start(*)
       24:       super
       25:     ensure
    => 26:       Bundler::SharedHelpers.print_major_deprecations!
       27:     end
       28:
       29:     def self.dispatch(*)
       30:       super do |i|
    (byebug)
    $
    ```
    
    ### When the setting is true
    ```
    $ cat ~/.byebugrc
    set histfile /home/gabrielx/byebug.history
    set ignore_empty_commands true
    $
    $ bundle exec ./test.rb
    
    [3, 12] in /home/gabrielx/projects/byebug/test.rb
        3:
        4: require 'byebug'
        5:
        6: debugger
        7:
    =>  8: sleep 2.1
        9: debugger
       10:
       11: sleep 2.2
       12: debugger
    (byebug) c
    
    [3, 12] in /home/gabrielx/projects/byebug/test.rb
        3:
        4: require 'byebug'
        5:
        6: debugger
        7:
        8: sleep 2.1
        9: debugger
       10:
    => 11: sleep 2.2
       12: debugger
    (byebug)
    (byebug)
    (byebug) c
    
    [21, 30] in /home/gabrielx/.rvm/gems/ruby-2.5.3/gems/bundler-2.2.0.rc.2/lib/bundler/cli.rb
       21:     }.freeze
       22:
       23:     def self.start(*)
       24:       super
       25:     ensure
    => 26:       Bundler::SharedHelpers.print_major_deprecations!
       27:     end
       28:
       29:     def self.dispatch(*)
       30:       super do |i|
    (byebug)
    (byebug)
    (byebug) c
    $
    ```
    gabrieldeal committed Dec 12, 2020
    Configuration menu
    Copy the full SHA
    c7122b3 View commit details
    Browse the repository at this point in the history
  2. Fix Rubocop offence.

    gabrieldeal committed Dec 12, 2020
    Configuration menu
    Copy the full SHA
    217e4d6 View commit details
    Browse the repository at this point in the history