Skip to content

Commit

Permalink
Fix #176 Correct ENV and LABEL's parameter calculation
Browse files Browse the repository at this point in the history
Signed-off-by: Remy Suen <[email protected]>
  • Loading branch information
rcjsuen committed Sep 15, 2017
1 parent f4e315c commit 1bb93a6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
### Fixed
- correct the documentation of HEALTHCHECK's --retries flag's completion item ([#170](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/170))
- show correct parameter in HEALTHCHECK's signature help if it has an escaped newline ([#175](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/175))
- show correct parameter in ENV and LABEL's signature help if it has an escaped newline ([#176](https://github.com/rcjsuen/dockerfile-language-server-nodejs/issues/176))

## [0.0.7] - 2017-09-09
### Added
Expand Down
7 changes: 6 additions & 1 deletion src/parser/property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ export class Property {
return false;
} else if (this.valueRange.start.line < position.line) {
return true;
} else if (this.valueRange.start.line === position.line) {
if (this.valueRange.start.line === this.valueRange.end.line) {
return this.valueRange.end.character < position.character;
}
return this.valueRange.start.character < position.character;
}
return this.valueRange.start.line === position.line ? this.valueRange.end.character < position.character : false;
return false;
}

public isInValue(position: Position): boolean {
Expand Down
20 changes: 20 additions & 0 deletions test/dockerSignatures.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,11 @@ describe("Dockerfile Signature Tests", function() {

assertAll(compute(prefix + " key ", 0, offset + 1));
assertAll(compute(prefix + " key ", 0, offset + 3));

assertAll(compute(prefix + " key \\\n", 0, offset + 1));
assertAll(compute(prefix + " key \\\n", 0, offset + 2));
assertAll(compute(prefix + " key \\\n", 0, offset + 3));
assertAll(compute(prefix + " key \\\n", 0, offset + 4));
});

it("space", function() {
Expand Down Expand Up @@ -1833,6 +1838,11 @@ describe("Dockerfile Signature Tests", function() {
assertSpaceOnly(compute(prefix + " key value spaced", 0, offset + 11), 1);
assertSpaceOnly(compute(prefix + " key value spaced", 0, offset + 13), 1);
assertSpaceOnly(compute(prefix + " key value spaced", 0, offset + 17), 1);

assertSpaceOnly(compute(prefix + " key \\\nvalue", 0, offset + 1), 0);
assertSpaceOnly(compute(prefix + " key \\\nvalue", 0, offset + 2), 0);
assertSpaceOnly(compute(prefix + " key \\\nvalue", 0, offset + 3), 0);
assertSpaceOnly(compute(prefix + " key \\\nvalue", 0, offset + 4), 0);
});

it("equals", function() {
Expand All @@ -1846,6 +1856,16 @@ describe("Dockerfile Signature Tests", function() {
assertEquals(compute(prefix + " key=value", 0, offset + 5), 1);
assertEquals(compute(prefix + " key=value", 0, offset + 7), 1);
assertEquals(compute(prefix + " key=value", 0, offset + 10), 1);

assertEquals(compute(prefix + " key=\\\n", 0, offset + 1), 0);
assertEquals(compute(prefix + " key=\\\n", 0, offset + 2), 0);
assertEquals(compute(prefix + " key=\\\n", 0, offset + 3), 0);
assertEquals(compute(prefix + " key=\\\n", 0, offset + 4), 0);

assertEquals(compute(prefix + " key=\\\nvalue", 0, offset + 1), 0);
assertEquals(compute(prefix + " key=\\\nvalue", 0, offset + 2), 0);
assertEquals(compute(prefix + " key=\\\nvalue", 0, offset + 3), 0);
assertEquals(compute(prefix + " key=\\\nvalue", 0, offset + 4), 0);
});

it("equals multiples", function() {
Expand Down

0 comments on commit 1bb93a6

Please sign in to comment.