From 2af3005f52edc62dd3b2e7632a6e5373ac932ef7 Mon Sep 17 00:00:00 2001 From: Remy Suen Date: Thu, 23 Oct 2025 10:44:05 -0400 Subject: [PATCH] Initialize the breakpoints map in the beginning Signed-off-by: Remy Suen --- dap/adapter.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dap/adapter.go b/dap/adapter.go index 68106654b..12e8bfae6 100644 --- a/dap/adapter.go +++ b/dap/adapter.go @@ -568,6 +568,9 @@ func newBreakpointMap() *breakpointMap { func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoints []dap.Breakpoint) { b.mu.Lock() 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] for _, sbp := range sbps { @@ -590,11 +593,6 @@ func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoi breakpoints = append(breakpoints, bp) } 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 }