dap: skip the load build context step when it doesn't have an associated source line

Skip the load build context step when it doesn't have an associated
source line. This caused an extra branch to be created in an otherwise
pretty straightforward dockerfile where stepping in on a copy
instruction that used the context would stay on the same line because it
"stepped into" the context loading rather than being treated the same as
step next.

This resulted in some bad and confusing ergonomics with the cursor
position that were a bit confusing and unexpected.

There might be more areas to try and prune but the most common one, a
single branch instruction that doesn't have a location, now gets skipped
which is the exact thing that was generated for loading the context.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
Jonathan A. Sternberg
2026-03-10 12:35:13 -05:00
parent a5f49f0c17
commit 3e4bd229ab
2 changed files with 14 additions and 49 deletions
-48
View File
@@ -299,54 +299,6 @@ func testDapBuildStepIn(t *testing.T, sb integration.Sandbox) {
Name: `^\[stage-1 .*\] COPY .* /etc/bar`,
},
},
// the following three steps are unintended and are the result
// of a bug in the debug adapter.
// see issue https://github.com/docker/buildx/issues/3565
{
{
Name: `^\[internal\] load build context`,
},
{
SourceName: "Dockerfile",
Line: 3,
Name: `^\[base .*\] COPY foo`,
},
{
SourceName: "Dockerfile",
Line: 7,
Name: `^\[stage-1 .*\] COPY .* /etc/bar`,
},
},
// todo: this shouldn't be a stop point.
{
{
Name: `^\[internal\] load build context`,
},
{
SourceName: "Dockerfile",
Line: 3,
Name: `^\[base .*\] COPY foo`,
},
{
SourceName: "Dockerfile",
Line: 7,
Name: `^\[stage-1 .*\] COPY .* /etc/bar`,
},
},
// duplicate of stop point 3 because of unintended branch
// associated with the build context copy.
{
{
SourceName: "Dockerfile",
Line: 3,
Name: `^\[base .*\] COPY foo`,
},
{
SourceName: "Dockerfile",
Line: 7,
Name: `^\[stage-1 .*\] COPY .* /etc/bar`,
},
},
// stop point 4
{
{