Skip to content

Commit 0b07a95

Browse files
committed
dap: Fix breakpoint overlap check
The old logic wasn't quite right, and a little hard to follow. Before this, because breakpoints sent from setBreakpoints don't have an end line or column they are just a single point the comparison would fail the check due to the column check. E.g. if I have a breakpoint on line 30. The content lines range from 29-31. Now lets say the end column is at postion 10, but my breakpoint is at L30 column 11 (still within range). The overlap check would fail because 11 > 10 but these shouldn't be compared at all in this case. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
1 parent 4826295 commit 0b07a95

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dap/adapter.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,16 @@ func (b *breakpointMap) Intersect(ctx Context, src *pb.Source, ws string) map[di
612612

613613
func (b *breakpointMap) intersect(ctx Context, src *pb.Source, locs *pb.Locations, ws string) int {
614614
overlaps := func(r *pb.Range, bp *dap.Breakpoint) bool {
615-
return r.Start.Line <= int32(bp.Line) && r.Start.Character <= int32(bp.Column) && r.End.Line >= int32(bp.EndLine) && r.End.Character >= int32(bp.EndColumn)
615+
if bp.Line < int(r.Start.Line) || bp.Line > int(r.End.Line) {
616+
return false
617+
}
618+
if bp.Line == int(r.Start.Line) && bp.Column < int(r.Start.Character) {
619+
return false
620+
}
621+
if bp.Line == int(r.End.Line) && bp.Column > int(r.End.Character) {
622+
return false
623+
}
624+
return true
616625
}
617626

618627
for _, loc := range locs.Locations {

0 commit comments

Comments
 (0)