Skip to content

Commit

Permalink
Hover doesn't work when there is now symbol after property (#382)
Browse files Browse the repository at this point in the history
* fix: validate the last yaml null prop

* fix: add test validate on null prop

Co-authored-by: Petr Spacek <[email protected]>
Co-authored-by: p-spacek <[email protected]>
  • Loading branch information
3 people committed Dec 23, 2020
1 parent d896e46 commit 8412e43
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/languageservice/parser/jsonParser07.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export function getNodePath(node: ASTNode): JSONPath {

export function contains(node: ASTNode, offset: number, includeRightBound = false): boolean {
return (
(offset >= node.offset && offset < node.offset + node.length) || (includeRightBound && offset === node.offset + node.length)
(offset >= node.offset && offset <= node.offset + node.length) || (includeRightBound && offset === node.offset + node.length)
);
}

Expand Down
20 changes: 20 additions & 0 deletions test/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,25 @@ suite('Hover Tests', () => {
})
.then(done, done);
});

it('Hover on null property', (done) => {
languageService.addSchema(SCHEMA_ID, {
type: 'object',
properties: {
childObject: {
type: 'object',
description: 'should return this description',
},
},
});
const content = 'childObject: \n';
const hover = parseSetup(content, 1);
hover
.then(function (result) {
assert.equal((result.contents as MarkedString[]).length, 1);
assert.equal(result.contents[0], 'should return this description');
})
.then(done, done);
});
});
});

0 comments on commit 8412e43

Please sign in to comment.