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

- Compose
- textDocument/completion
- prevent errors if an empty JSON object is the content of the YAML file ([#330](https://github.com/docker/docker-language-server/issues/330))

## [0.12.0] - 2025-06-12

### Added
Expand Down
3 changes: 3 additions & 0 deletions internal/compose/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func Completion(ctx context.Context, params *protocol.CompletionParams, manager
if file == nil || len(file.Docs) == 0 {
return nil, nil
}
if m, ok := file.Docs[0].Body.(*ast.MappingNode); ok && len(m.Values) == 0 {
return nil, nil
}

lspLine := int(params.Position.Line)
topLevelNodeOffset := calculateTopLevelNodeOffset(file)
Expand Down
7 changes: 7 additions & 0 deletions internal/compose/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2762,6 +2762,13 @@ services:
},
},
},
{
name: "empty JSON object",
content: "{}",
line: 0,
character: 0,
list: nil,
},
}

composeFileURI := fmt.Sprintf("file:///%v", strings.TrimPrefix(filepath.ToSlash(filepath.Join(os.TempDir(), "compose.yaml")), "/"))
Expand Down
Loading