From 8e226d01f7d3d2a0923a9b899c4f2d11798fd62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez=20de=20Dios?= Date: Thu, 14 Aug 2014 16:42:42 +0200 Subject: [PATCH] Remove stepping capabilities in `irb` command There are several reasons for this: - `next` command inside `irb` never really worked, because the `next` keyword in Ruby would get executed instead (see https://github.com/nixme/pry-nav/issues/20) - Commands were very limited, they couldn't handle any arguments like the regular `next`, `step` and `cont` commands. - It causes issues with the Rails console (see [https://github.com/deivid-rodriguez/pry-byebug/issues/30). --- lib/byebug/commands/repl.rb | 46 ++----------------------------------- test/irb_test.rb | 18 +++------------ 2 files changed, 5 insertions(+), 59 deletions(-) diff --git a/lib/byebug/commands/repl.rb b/lib/byebug/commands/repl.rb index 1e6041887..56986fb25 100644 --- a/lib/byebug/commands/repl.rb +++ b/lib/byebug/commands/repl.rb @@ -1,27 +1,4 @@ -module IRB - module ExtendCommand - class Continue - def self.execute(conf) - throw :IRB_EXIT, :cont - end - end - class Next - def self.execute(conf) - throw :IRB_EXIT, :next - end - end - class Step - def self.execute(conf) - throw :IRB_EXIT, :step - end - end - end - - require 'irb' - ExtendCommandBundle.def_extend_command 'cont', :Continue - ExtendCommandBundle.def_extend_command 'next', :Next - ExtendCommandBundle.def_extend_command 'step', :Step -end +require 'irb' module Byebug class IrbCommand < Command @@ -36,21 +13,6 @@ def execute end cont = IRB.start(__FILE__) - case cont - when :cont - @state.proceed - when :step - force = Setting[:forcestep] - @state.context.step_into 1, force - @state.proceed - when :next - force = Setting[:forcestep] - @state.context.step_over 1, @state.frame_pos, force - @state.proceed - else - print @state.location - @state.previous_line = nil - end end class << self @@ -59,11 +21,7 @@ def names end def description - %{irb\tstarts an Interactive Ruby (IRB) session. - - IRB is extended with methods "cont", "n" and "step" which run the - corresponding byebug commands. In contrast to the real byebug commands - these commands don't allow arguments.} + %{irb\tstarts an Interactive Ruby (IRB) session.} end end end diff --git a/test/irb_test.rb b/test/irb_test.rb index c98e756a3..57f525d28 100644 --- a/test/irb_test.rb +++ b/test/irb_test.rb @@ -15,22 +15,10 @@ def setup interface.stubs(:kind_of?).with(LocalInterface).returns(true) end - def test_irb_supports_next_command - IRB::Irb.any_instance.stubs(:eval_input).throws(:IRB_EXIT, :next) + def test_irb_command_starts_an_irb_session + IrbCommand.any_instance.expects(:execute) enter 'irb' - debug_proc(@example) { assert_equal 7, state.line } - end - - def test_irb_supports_step_command - IRB::Irb.any_instance.stubs(:eval_input).throws(:IRB_EXIT, :step) - enter 'irb' - debug_proc(@example) { assert_equal 7, state.line } - end - - def test_irb_supports_cont_command - IRB::Irb.any_instance.stubs(:eval_input).throws(:IRB_EXIT, :cont) - enter 'break 8', 'irb' - debug_proc(@example) { assert_equal 8, state.line } + debug_proc(@example) end def test_autoirb_calls_irb_automatically_after_every_stop