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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to the Docker Language Server will be documented in this file.

## [Unreleased]

### Fixed

- Bake
- textDocument/completion
- check the type of the block before suggesting items ([#422](https://github.com/docker/docker-language-server/issues/422))

## [0.16.0] - 2025-08-12

### Added
Expand Down
2 changes: 1 addition & 1 deletion internal/bake/hcl/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Completion(ctx context.Context, params *protocol.CompletionParams, manager
}

for _, b := range body.Blocks {
if isInsideBodyRangeLines(b.Body, int(params.Position.Line)+1) {
if b.Type == "target" && isInsideBodyRangeLines(b.Body, int(params.Position.Line)+1) {
attributes := b.Body.Attributes
if attribute, ok := attributes["inherits"]; ok && isInsideRange(attribute.Expr.Range(), params.Position) {
if tupleConsExpr, ok := attribute.Expr.(*hclsyntax.TupleConsExpr); ok {
Expand Down
14 changes: 14 additions & 0 deletions internal/bake/hcl/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,20 @@ func TestCompletion(t *testing.T) {
},
},
},
{
name: "inherits attribute should not suggest anything in a variable block",
content: "variable \"var\" {\n inherits = [\"\"]\n}\ntarget \"base\" {}",
line: 1,
character: 15,
items: []protocol.CompletionItem{},
},
{
name: "network attribute should not suggest anything in a variable block",
content: "variable \"var\" {\n network = \"\"\n}\ntarget \"base\" {}",
line: 1,
character: 13,
items: []protocol.CompletionItem{},
},
}

bakeFilePath := filepath.Join(completionTestFolderPath, "docker-bake.hcl")
Expand Down
Loading