Skip to content

Commit

Permalink
Fix #258 Correct error response in COPY completion items
Browse files Browse the repository at this point in the history
If textDocument/completion is received at the end of a COPY instruction
with flags, an error response will no longer be sent back.

Signed-off-by: Remy Suen <remy.suen@gmail.com>
  • Loading branch information
rcjsuen committed Dec 12, 2021
1 parent 4ed1f60 commit 02eb2ca
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## [Unreleased]
### Fixed
- textDocument/completion
- fix error returned when computing completion items at the end of a COPY instruction with flags ([#258](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/258))

## [0.7.2] - 2021-10-20
### Fixed
- textDocument/semanticTokens/full
Expand Down
72 changes: 61 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"node": "*"
},
"dependencies": {
"dockerfile-language-service": "0.7.3",
"dockerfile-language-service": "0.7.4",
"dockerfile-utils": "0.9.2",
"vscode-languageserver": "^8.0.0-next.2"
},
Expand Down
38 changes: 38 additions & 0 deletions test/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,44 @@ describe("Dockerfile LSP Tests", function() {
});
});

it("issue #258", (finished) => {
const uri = "uri://dockerfile/258.txt";
this.timeout(5000);
sendNotification("textDocument/didOpen", {
textDocument: {
languageId: "dockerfile",
version: 1,
uri: uri,
text: "COPY --from=a "
}
});
let id = sendRequest("textDocument/completion", {
textDocument: { uri: uri },
position: { line: 0, character: 14 }
});

const listener258 = (json) => {
if (json.id === id) {
lspProcess.removeListener("message", listener258);
sendNotification("textDocument/didClose", {
textDocument: { uri: uri }
});
assert.strictEqual(json.result.length, 1);
assert.strictEqual(json.result[0].data, "COPY_FlagChown");
assert.strictEqual(json.result[0].label, "--chown=");
assert.strictEqual(json.result[0].kind, CompletionItemKind.Field);
assert.strictEqual(json.result[0].insertTextFormat, InsertTextFormat.PlainText);
assert.strictEqual(json.result[0].textEdit.newText, "--chown=");
assert.strictEqual(json.result[0].textEdit.range.start.line, 0);
assert.strictEqual(json.result[0].textEdit.range.start.character, 14);
assert.strictEqual(json.result[0].textEdit.range.end.line, 0);
assert.strictEqual(json.result[0].textEdit.range.end.character, 14);
finished();
}
};
lspProcess.on("message", listener258);
});

after(() => {
// terminate the forked LSP process after all the tests have been run
lspProcess.kill();
Expand Down

0 comments on commit 02eb2ca

Please sign in to comment.