Skip to content

Commit 5b8b65a

Browse files
committed
dap: next and out now respect breakpoints
If a breakpoint occurs before the step pointed to by next or out, dap will now stop there instead of the desired location. This also updates the loop to always set the breakpoints rather than only when continue is chosen. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
1 parent 00502c0 commit 5b8b65a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

dap/thread.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ func (t *thread) Evaluate(ctx Context, c gateway.Client, headRef gateway.Referen
9494
return err
9595
}
9696

97-
if action == stepContinue {
98-
t.setBreakpoints(ctx)
99-
}
97+
t.setBreakpoints(ctx)
10098
k, next, refs, err = t.seekNext(ctx, next, action)
10199
}
102100
return nil
@@ -464,13 +462,13 @@ func (t *thread) seekNext(ctx Context, from *step, action stepType) (string, *st
464462
var target *step
465463
switch action {
466464
case stepNext:
467-
target = from.next
465+
target = t.continueDigest(from, from.next)
468466
case stepIn:
469467
target = from.in
470468
case stepOut:
471-
target = from.out
469+
target = t.continueDigest(from, from.out)
472470
case stepContinue:
473-
target = t.continueDigest(from)
471+
target = t.continueDigest(from, nil)
474472
}
475473
return t.seek(ctx, target)
476474
}
@@ -497,8 +495,8 @@ func (t *thread) seek(ctx Context, target *step) (k string, result *step, mounts
497495
return k, result, refs, nil
498496
}
499497

500-
func (t *thread) continueDigest(from *step) *step {
501-
if len(t.bps) == 0 {
498+
func (t *thread) continueDigest(from, until *step) *step {
499+
if len(t.bps) == 0 && until == nil {
502500
return nil
503501
}
504502

@@ -513,13 +511,13 @@ func (t *thread) continueDigest(from *step) *step {
513511

514512
next := func(s *step) *step {
515513
cur := s.in
516-
for cur != nil {
514+
for cur != nil && cur != until {
517515
if isBreakpoint(cur.dgst) {
518516
return cur
519517
}
520518
cur = cur.in
521519
}
522-
return nil
520+
return until
523521
}
524522
return next(from)
525523
}

0 commit comments

Comments
 (0)