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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ Command | Aliases | Subcommands
`quit!` | `q!` |
`restart` | |
`save` | `sa` |
`set` | | `autoirb` `autolist` `autopry` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `width`
`show` | | `autoirb` `autolist` `autopry` `autosave` `basename` `callstyle` `fullpath` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `width`
`set` | | `autoirb` `autolist` `autopry` `autosave` `basename` `callstyle` `fullpath` `ignore_empty_commands` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `width`
`show` | | `autoirb` `autolist` `autopry` `autosave` `basename` `callstyle` `fullpath` `ignore_empty_commands` `histfile` `histsize` `linetrace` `listsize` `post_mortem` `savefile` `stack_on_error` `width`
`skip` | `sk` |
`source` | `so` |
`step` | `s` |
Expand Down
2 changes: 2 additions & 0 deletions lib/byebug/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def prepare_input(prompt)
line = readline(prompt)
return unless line

return "" if line.empty? && Setting[:ignore_empty_commands]

last_if_empty(line)
end

Expand Down
17 changes: 17 additions & 0 deletions lib/byebug/settings/ignore_empty_commands.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require_relative "../setting"

module Byebug
#
# Setting to control what Byebug does when the user enters an empty
# command (presses enter without a command).
#
class IgnoreEmptyCommandsSetting < Setting
DEFAULT = false

def banner
"Enable/disable running the last command upon empty commands"
end
end
end
2 changes: 1 addition & 1 deletion test/commands/set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def program
end

settings =
%i[autolist autosave basename fullpath post_mortem stack_on_error]
%i[autolist autosave basename fullpath ignore_empty_commands post_mortem stack_on_error]

settings.each do |set|
["on", "1", "true", ""].each do |key|
Expand Down
8 changes: 8 additions & 0 deletions test/processors/command_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def test_empty_command_repeats_last_command
debug_code(program) { assert_equal 6, frame.line }
end

def test_empty_command_does_not_repeat_last_command_when_ignoring_empty_commands
with_setting :ignore_empty_commands, true do
enter "n", ""

debug_code(program) { assert_equal 5, frame.line }
end
end

def test_multiple_commands_are_executed_sequentially
enter "n ; n"

Expand Down