99 "path"
1010 "path/filepath"
1111 "slices"
12+ "strings"
1213 "sync"
1314 "sync/atomic"
1415
@@ -573,7 +574,9 @@ func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoi
573574 // null back in the JSON if there are no breakpoints
574575 breakpoints = []dap.Breakpoint {}
575576
576- prev := b .byPath [fname ]
577+ // Use lowercase paths to normalize the case. We can only know the correct casing after
578+ // we intersect the breakpoint map. When we report the pending breakpoint to the editor,
579+ prev := b .getByPath (fname )
577580 for _ , sbp := range sbps {
578581 index := slices .IndexFunc (prev , func (e dap.Breakpoint ) bool {
579582 return sbp .Line >= e .Line && sbp .Line <= e .EndLine && sbp .Column >= e .Column && sbp .Column <= e .EndColumn
@@ -589,12 +592,16 @@ func (b *breakpointMap) Set(fname string, sbps []dap.SourceBreakpoint) (breakpoi
589592 EndLine : sbp .Line ,
590593 Column : sbp .Column ,
591594 EndColumn : sbp .Column ,
592- Reason : "pending" ,
595+ Source : & dap.Source {
596+ Name : path .Base (fname ),
597+ Path : fname ,
598+ },
599+ Reason : "pending" ,
593600 }
594601 }
595602 breakpoints = append (breakpoints , bp )
596603 }
597- b .byPath [ fname ] = breakpoints
604+ b .setByPath ( fname , breakpoints )
598605 return breakpoints
599606}
600607
@@ -615,7 +622,7 @@ func (b *breakpointMap) Intersect(ctx Context, src *pb.Source, ws string) map[di
615622 for _ , info := range src .Infos {
616623 fname := filepath .Join (ws , info .Filename )
617624
618- bps := b .byPath [ fname ]
625+ bps := b .getByPath ( fname )
619626 for _ , bp := range bps {
620627 if ! bp .Verified && bp .Reason != "failed" {
621628 bp .Reason = "failed"
@@ -656,7 +663,7 @@ func (b *breakpointMap) intersect(ctx Context, src *pb.Source, locs *pb.Location
656663 info := src .Infos [loc .SourceIndex ]
657664 fname := filepath .Join (ws , info .Filename )
658665
659- bps := b .byPath [ fname ]
666+ bps := b .getByPath ( fname )
660667 if len (bps ) == 0 {
661668 // No breakpoints for this file.
662669 continue
@@ -675,6 +682,13 @@ func (b *breakpointMap) intersect(ctx Context, src *pb.Source, locs *pb.Location
675682 bp .Verified = true
676683 bp .Reason = ""
677684
685+ // The path from the source might be different than the path
686+ // the editor sent to us just because of different casing.
687+ // Prefer the version given to us from buildkit and tell
688+ // the editor what the proper casing for this should be.
689+ bp .Source .Name = path .Base (fname )
690+ bp .Source .Path = fname
691+
678692 ctx .C () <- & dap.BreakpointEvent {
679693 Event : dap.Event {Event : "breakpoint" },
680694 Body : dap.BreakpointEventBody {
@@ -689,3 +703,11 @@ func (b *breakpointMap) intersect(ctx Context, src *pb.Source, locs *pb.Location
689703 }
690704 return 0
691705}
706+
707+ func (b * breakpointMap ) setByPath (fname string , bps []dap.Breakpoint ) {
708+ b .byPath [strings .ToLower (fname )] = bps
709+ }
710+
711+ func (b * breakpointMap ) getByPath (fname string ) []dap.Breakpoint {
712+ return b .byPath [strings .ToLower (fname )]
713+ }
0 commit comments