File tree 2 files changed +89
-7
lines changed
2 files changed +89
-7
lines changed Original file line number Diff line number Diff line change @@ -273,13 +273,10 @@ def try_activate root_iseq = nil
273
273
274
274
if !nearest || ( ( line - nline ) . abs < ( line - nearest . line ) . abs )
275
275
nearest = NearestISeq . new ( iseq , nline , events )
276
- else
277
- if @hook_call && nearest . iseq . first_lineno <= iseq . first_lineno
278
- if ( nearest . line > line && !nearest . events . include? ( :RUBY_EVENT_CALL ) ) ||
279
- ( events . include? ( :RUBY_EVENT_CALL ) )
280
- nearest = NearestISeq . new ( iseq , nline , events )
281
- end
282
- end
276
+ elsif @hook_call &&
277
+ nearest . line == iseq . first_line &&
278
+ events . include? ( :RUBY_EVENT_CALL )
279
+ nearest = NearestISeq . new ( iseq , nline , events )
283
280
end
284
281
end
285
282
end
Original file line number Diff line number Diff line change @@ -838,4 +838,89 @@ def test_break_on_realoded_file
838
838
end
839
839
end
840
840
end
841
+
842
+ class BreakAtLineTest < ConsoleTestCase
843
+ def program path
844
+ <<~RUBY
845
+ 1| load #{ path . dump }
846
+ RUBY
847
+ end
848
+
849
+ def extra_file
850
+ <<~RUBY
851
+ a = 1
852
+
853
+ class C
854
+ def m
855
+ p :m
856
+ end
857
+ end
858
+ RUBY
859
+ end
860
+
861
+ def test_break_on_line
862
+ with_extra_tempfile do |extra_file |
863
+ debug_code program ( extra_file . path ) do
864
+ type "break #{ extra_file . path } :1"
865
+ type 'c'
866
+ assert_line_num 1
867
+ type 'c'
868
+ end
869
+ end
870
+ end
871
+
872
+ def program2
873
+ <<~RUBY
874
+ 1| a = 1
875
+ 2| b = 2 # braek 2, stop at 2
876
+ 3| # break 3, stop at def
877
+ 4| def foo # break 4, stop at 5 (in foo)
878
+ 5| a = 2
879
+ 6| end
880
+ 7|
881
+ 8| private def bar # break 8, stop at 9 (in bar)
882
+ 9| a = 3
883
+ 10| end
884
+ 11|
885
+ 12| foo
886
+ 13| bar
887
+ RUBY
888
+ end
889
+
890
+ def test_break_on_line_2
891
+ debug_code program2 do
892
+ type 'b 2'
893
+ type 'c'
894
+ assert_line_num 2
895
+ type 'c'
896
+ end
897
+ end
898
+
899
+ def test_break_on_line_3
900
+ debug_code program2 do
901
+ type 'b 3'
902
+ type 'c'
903
+ assert_line_num 4
904
+ type 'c'
905
+ end
906
+ end
907
+
908
+ def test_break_on_line_4
909
+ debug_code program2 do
910
+ type 'b 4'
911
+ type 'c'
912
+ assert_line_num 5
913
+ type 'c'
914
+ end
915
+ end
916
+
917
+ def test_break_on_line_8
918
+ debug_code program2 do
919
+ type 'b 8'
920
+ type 'c'
921
+ assert_line_num 9
922
+ type 'c'
923
+ end
924
+ end
925
+ end
841
926
end
You can’t perform that action at this time.
0 commit comments