Skip to content

Commit

Permalink
Avoid overriding user's irb_name setting in debugger integration
Browse files Browse the repository at this point in the history
Instead of always setting `irb_name` to `irb:rdbg`, it should respect
the user's setting and only append `:rdbg` to it.
  • Loading branch information
st0012 committed Aug 21, 2023
1 parent 399b872 commit abcf12a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/irb/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def configure_irb_for_debugger(irb)
require 'irb/debug/ui'
IRB.instance_variable_set(:@debugger_irb, irb)
irb.context.with_debugger = true
irb.context.irb_name = "irb:rdbg"
irb.context.irb_name += ":rdbg"
end

def binding_irb?
Expand Down
24 changes: 24 additions & 0 deletions test/irb/test_debug_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,30 @@ def test_prompt_line_number_continues
assert_match(/irb:rdbg\(main\):005> next/, output)
end

def test_prompt_irb_name_is_kept
@irbrc = Tempfile.new('irbrc')
@irbrc.write <<~RUBY
IRB.conf[:IRB_NAME] = "foo"
RUBY
@irbrc.close
@envs['IRBRC'] = @irbrc.path

write_ruby <<~'ruby'
binding.irb
puts "Hello"
ruby

output = run_ruby_file do
type "next"
type "continue"
end

assert_match(/foo\(main\):001> next/, output)
assert_match(/foo:rdbg\(main\):002> continue/, output)
ensure
@irbrc&.unlink
end

def test_irb_commands_are_available_after_moving_around_with_the_debugger
write_ruby <<~'ruby'
class Foo
Expand Down

0 comments on commit abcf12a

Please sign in to comment.