Initialize the breakpoints map in the beginning

Signed-off-by: Remy Suen <remy.suen@docker.com>
This commit is contained in:
Remy Suen
2025-10-23 10:44:05 -04:00
parent 7c4dd41cb0
commit 2af3005f52
+3 -5
View File
@@ -568,6 +568,9 @@ func newBreakpointMap() *breakpointMap {
func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoints []dap.Breakpoint) { func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoints []dap.Breakpoint) {
b.mu.Lock() b.mu.Lock()
defer b.mu.Unlock() defer b.mu.Unlock()
// explicitly initialize breakpoints so that
// we do not send a null back in the JSON if there are no breakpoints
breakpoints = []dap.Breakpoint{}
prev := b.byPath[fname] prev := b.byPath[fname]
for _, sbp := range sbps { for _, sbp := range sbps {
@@ -590,11 +593,6 @@ func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoi
breakpoints = append(breakpoints, bp) breakpoints = append(breakpoints, bp)
} }
b.byPath[fname] = breakpoints b.byPath[fname] = breakpoints
if breakpoints == nil {
// explicitly initialize breakpoints so that
// we do not send a null back in the JSON if there are no breakpoints
breakpoints = []dap.Breakpoint{}
}
return breakpoints return breakpoints
} }