Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ All notable changes to the Docker Language Server will be documented in this fil
- Bake
- textDocument/codeLens
- refactor the URI handling code so it will accept a WSL URI with a dollar sign ([#388](https://github.com/docker/docker-language-server/issues/388))
- textDocument/definition
- handle WSL URIs with a dollar sign properly to fix file looks up on those hosts ([#390](https://github.com/docker/docker-language-server/issues/390))
- textDocument/documentLink
- convert links properly if a WSL URI with a dollar sign is used ([#378](https://github.com/docker/docker-language-server/issues/378))
- textDocument/inlineCompletion
Expand Down
6 changes: 3 additions & 3 deletions internal/bake/hcl/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ func ResolveExpression(ctx context.Context, definitionLinkSupport bool, manager

if literalValueExpr, ok := expression.(*hclsyntax.LiteralValueExpr); ok && sourceBlock != nil && sourceBlock.Type == "target" {
if attributeName == "no-cache-filter" || attributeName == "target" {
dockerfilePath, err := doc.DockerfileForTarget(sourceBlock)
dockerfileURI, dockerfilePath, err := doc.DockerfileDocumentPathForTarget(sourceBlock)
if dockerfilePath == "" || err != nil {
return nil
}

value, _ := literalValueExpr.Value(&hcl.EvalContext{})
target := value.AsString()

bytes, nodes := document.OpenDockerfile(ctx, manager, "", dockerfilePath)
bytes, nodes := document.OpenDockerfile(ctx, manager, dockerfileURI, dockerfilePath)
lines := strings.Split(string(bytes), "\n")
for _, child := range nodes {
if strings.EqualFold(child.Value, "FROM") {
Expand Down Expand Up @@ -154,7 +154,7 @@ func ResolveExpression(ctx context.Context, definitionLinkSupport bool, manager
Character: uint32(uint32(literalValueExpr.Range().End.Column) - 1),
},
},
protocol.URI(fmt.Sprintf("file:///%v", strings.TrimPrefix(filepath.ToSlash(dockerfilePath), "/"))),
protocol.URI(dockerfileURI),
)
}
}
Expand Down
Loading
Loading