Skip to content

Commit a6893b6

Browse files
authored
Merge pull request #493 from docker/compose-empty-prefix-completion-fix
Ignore empty prefixes when processing image tag completions
2 parents 03efb88 + e5c80a7 commit a6893b6

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ All notable changes to the Docker Language Server will be documented in this fil
66

77
### Fixed
88

9+
- Compose
10+
- textDocument/completion
11+
- check the prefix string before trying to use it for looking up image tags ([#486](https://github.com/docker/docker-language-server/issues/486))
912
- Bake
1013
- fix parsing error caused by referencing a variable with no value ([#490](https://github.com/docker/docker-language-server/issues/490))
1114

internal/compose/completion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ func buildTargetCompletionItems(params *protocol.CompletionParams, manager *docu
582582
}
583583

584584
func serviceImageCompletionItems(hub hub.Service, path []*ast.MappingValueNode, prefix string) ([]protocol.CompletionItem, bool) {
585-
if len(path) == 3 && path[0].Key.GetToken().Value == "services" && path[2].Key.GetToken().Value == "image" {
585+
if len(path) == 3 && path[0].Key.GetToken().Value == "services" && path[2].Key.GetToken().Value == "image" && len(prefix) > 0 {
586586
if path[2].Value.GetToken().Type == token.DoubleQuoteType || path[2].Value.GetToken().Type == token.SingleQuoteType {
587587
prefix = prefix[1:]
588588
}

internal/compose/completion_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5509,6 +5509,26 @@ services:
55095509
character: 15,
55105510
list: nil,
55115511
},
5512+
{
5513+
name: "single quoted completion with whitespace preceding the character position",
5514+
content: `
5515+
services:
5516+
test:
5517+
image: ' '`,
5518+
line: 3,
5519+
character: 13,
5520+
list: nil,
5521+
},
5522+
{
5523+
name: "double quoted completion with whitespace preceding the character position",
5524+
content: `
5525+
services:
5526+
test:
5527+
image: " "`,
5528+
line: 3,
5529+
character: 13,
5530+
list: nil,
5531+
},
55125532
}
55135533

55145534
dir := createFileStructure(t)

0 commit comments

Comments
 (0)