Skip to content

Commit a2ca425

Browse files
authored
Merge pull request #162 from docker/object-schema-compose-fix
Suggest completion items for Compose arrays with an object schema
2 parents 543dc33 + 5ab19cc commit a2ca425

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

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

5+
## [Unreleased]
6+
7+
### Added
8+
9+
- Compose
10+
- improve code completion by automatically including required attributes in completion items ([#155](https://github.com/docker/docker-language-server/issues/155))
11+
12+
### Fixed
13+
14+
- Compose
15+
- suggest completion items for array items that use an object schema directly ([#161](https://github.com/docker/docker-language-server/issues/161))
16+
517
## [0.5.0] - 2025-05-05
618

719
### Added

internal/compose/completion_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,63 @@ services:
11511151
},
11521152
},
11531153
},
1154+
{
1155+
name: "attributes of the develop's watch array items",
1156+
content: `
1157+
services:
1158+
postgres:
1159+
develop:
1160+
watch:
1161+
- `,
1162+
line: 5,
1163+
character: 10,
1164+
list: &protocol.CompletionList{
1165+
Items: []protocol.CompletionItem{
1166+
{
1167+
Label: "action",
1168+
Detail: types.CreateStringPointer("string"),
1169+
TextEdit: textEdit("action: ${1|rebuild,restart,sync,sync+exec,sync+restart|}", 5, 10, 0),
1170+
InsertTextMode: types.CreateInsertTextModePointer(protocol.InsertTextModeAsIs),
1171+
InsertTextFormat: types.CreateInsertTextFormatPointer(protocol.InsertTextFormatSnippet),
1172+
},
1173+
{
1174+
Label: "exec",
1175+
Detail: types.CreateStringPointer("object"),
1176+
TextEdit: textEdit("exec:\n ", 5, 10, 0),
1177+
InsertTextMode: types.CreateInsertTextModePointer(protocol.InsertTextModeAsIs),
1178+
InsertTextFormat: types.CreateInsertTextFormatPointer(protocol.InsertTextFormatSnippet),
1179+
},
1180+
{
1181+
Label: "ignore",
1182+
Detail: types.CreateStringPointer("array or string"),
1183+
TextEdit: textEdit("ignore:", 5, 10, 0),
1184+
InsertTextMode: types.CreateInsertTextModePointer(protocol.InsertTextModeAsIs),
1185+
InsertTextFormat: types.CreateInsertTextFormatPointer(protocol.InsertTextFormatSnippet),
1186+
},
1187+
{
1188+
Label: "include",
1189+
Detail: types.CreateStringPointer("array or string"),
1190+
TextEdit: textEdit("include:", 5, 10, 0),
1191+
InsertTextMode: types.CreateInsertTextModePointer(protocol.InsertTextModeAsIs),
1192+
InsertTextFormat: types.CreateInsertTextFormatPointer(protocol.InsertTextFormatSnippet),
1193+
},
1194+
{
1195+
Label: "path",
1196+
Detail: types.CreateStringPointer("string"),
1197+
TextEdit: textEdit("path: ", 5, 10, 0),
1198+
InsertTextMode: types.CreateInsertTextModePointer(protocol.InsertTextModeAsIs),
1199+
InsertTextFormat: types.CreateInsertTextFormatPointer(protocol.InsertTextFormatSnippet),
1200+
},
1201+
{
1202+
Label: "target",
1203+
Detail: types.CreateStringPointer("string"),
1204+
TextEdit: textEdit("target: ", 5, 10, 0),
1205+
InsertTextMode: types.CreateInsertTextModePointer(protocol.InsertTextModeAsIs),
1206+
InsertTextFormat: types.CreateInsertTextFormatPointer(protocol.InsertTextFormatSnippet),
1207+
},
1208+
},
1209+
},
1210+
},
11541211
{
11551212
name: "inner attributes of the deploy/resources object under service",
11561213
content: `

internal/compose/schema.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func recurseNodeProperties(nodes []*ast.MappingValueNode, line, column, nodeOffs
119119
}
120120
}
121121
}
122+
return recurseNodeProperties(nodes, line, column, nodeOffset+1, schema.Properties, true)
122123
}
123124

124125
if nodes[nodeOffset].Key.GetToken().Position.Column < column {

0 commit comments

Comments
 (0)