Skip to content

Commit

Permalink
Hide debugger hint after the input is submitted (#789)
Browse files Browse the repository at this point in the history
If `output_modifier_proc`'s `complete` arg is true, it means the input is
submitted. In that case, debugger hint doesn't provide value to users
and adds noise to the output. So we hide it in such case.
  • Loading branch information
st0012 committed Nov 27, 2023
1 parent 2a0eacc commit f86d9db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/irb/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def DEBUGGER__.capture_frames(*args)
unless output.strip.empty?
cmd = output.split(/\s/, 2).first

if DEBUGGER__.commands.key?(cmd)
if !complete && DEBUGGER__.commands.key?(cmd)
output = output.sub(/\n$/, " # debug command\n")
end
end
Expand Down
8 changes: 6 additions & 2 deletions test/irb/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,15 @@ def test_debug_integration_hints_debugger_commands
script.close
start_terminal(40, 80, %W{ruby -I#{@pwd}/lib #{script.to_path}}, startup_message: 'start IRB')
write("debug\n")
write("n")
write("pp 1\n")
write("pp 1")
close

screen = result.join("\n").sub(/\n*\z/, "\n")
assert_include(screen, "irb:rdbg(main):002> n # debug command")
# submitted input shouldn't contain hint
assert_include(screen, "irb:rdbg(main):002> pp 1\n")
# unsubmitted input should contain hint
assert_include(screen, "irb:rdbg(main):003> pp 1 # debug command\n")
ensure
File.unlink(script) if script
end
Expand Down

0 comments on commit f86d9db

Please sign in to comment.