Skip to content

Ensure hover results are returned for files with CRLFs #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025
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 @@ -26,6 +26,8 @@ All notable changes to the Docker Language Server will be documented in this fil
- Compose
- textDocument/completion
- fix panic in code completion in an empty file ([#196](https://github.com/docker/docker-language-server/issues/196))
- textDocument/hover
- ensure results are returned even if the file has CRLFs ([#205](https://github.com/docker/docker-language-server/issues/205))
- Bake
- textDocument/publishDiagnostics
- stop flagging `BUILDKIT_SYNTAX` as an unrecognized `ARG` ([#187](https://github.com/docker/docker-language-server/issues/187))
Expand Down
39 changes: 39 additions & 0 deletions internal/compose/hover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,45 @@ services:
},
},
},
{
name: "container_name attribute on services",
content: `
services:
test:
container_name: abc`,
line: 3,
character: 7,
result: &protocol.Hover{
Contents: protocol.MarkupContent{
Kind: protocol.MarkupKindMarkdown,
Value: "Specify a custom container name, rather than a generated default name.\n\nSchema: [compose-spec.json](https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json)\n\n[Online documentation](https://docs.docker.com/reference/compose-file/services/#container_name)",
},
},
},
{
name: "container_name attribute with a comment before it",
content: "services:\n test:\n#\n container_name: abc",
line: 3,
character: 7,
result: &protocol.Hover{
Contents: protocol.MarkupContent{
Kind: protocol.MarkupKindMarkdown,
Value: "Specify a custom container name, rather than a generated default name.\n\nSchema: [compose-spec.json](https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json)\n\n[Online documentation](https://docs.docker.com/reference/compose-file/services/#container_name)",
},
},
},
{
name: "container_name attribute with a comment before it (CRLF)",
content: "services:\r\n test:\r\n#\r\n container_name: abc",
line: 3,
character: 7,
result: &protocol.Hover{
Contents: protocol.MarkupContent{
Kind: protocol.MarkupKindMarkdown,
Value: "Specify a custom container name, rather than a generated default name.\n\nSchema: [compose-spec.json](https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json)\n\n[Online documentation](https://docs.docker.com/reference/compose-file/services/#container_name)",
},
},
},
}

temporaryBakeFile := fmt.Sprintf("file:///%v", strings.TrimPrefix(filepath.ToSlash(filepath.Join(os.TempDir(), "compose.yaml")), "/"))
Expand Down
5 changes: 4 additions & 1 deletion internal/pkg/document/dockerComposeDocument.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ func NewComposeDocument(mgr *Manager, u uri.URI, version int32, input []byte) Co
uri: u,
identifier: protocol.DockerComposeLanguage,
version: version,
input: input,
// change all CRLF to LFs
// https://github.com/goccy/go-yaml/issues/560
// https://github.com/docker/docker-language-server/issues/205
input: []byte(strings.Replace(string(input), "\r\n", "\n", -1)),
},
mgr: mgr,
}
Expand Down
Loading