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
Setting to disable using the last command if the current command is empty #700
Comments
Hi @gabrielmdeal, sorry for the lack of reply so far. I'm good with adding what you propose 👍. |
gabrieldeal
added a commit
to gabrieldeal/byebug
that referenced
this issue
Dec 12, 2020
Add `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
added a commit
to gabrieldeal/byebug
that referenced
this issue
Dec 12, 2020
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 $ ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to be able to configure Byebug to treat empty commands as no-ops instead of treating them as if the user re-typed their last command. This is 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 (oftencontinue
).I was wondering what you thought about adding a new
set empty_command do_nothing | run_last
setting to https://github.com/deivid-rodriguez/byebug/tree/master/lib/byebug/settings and using the new setting in https://github.com/deivid-rodriguez/byebug/blob/e1fb8209d56922f7bafd128af84e61568b6cd6a7/lib/byebug/interface.rbI might be able to submit a PR if this idea sounds good to you.
The text was updated successfully, but these errors were encountered: