fix(language-service): [Ivy] hybrid visitor should not locate let keyword (#39061)
Fixed a boolean logic error that prevented hybrid visitor from returning undefined when a variable does not have value and cursor is not in the key span. PR Close #39061
This commit is contained in:
parent
246de9aaad
commit
70e13dc31e
|
@ -27,9 +27,11 @@ export function findNodeAtPosition(ast: t.Node[], position: number): t.Node|e.AS
|
|||
}
|
||||
if (isTemplateNodeWithKeyAndValue(candidate)) {
|
||||
const {keySpan, valueSpan} = candidate;
|
||||
const isWithinKeyValue =
|
||||
isWithin(position, keySpan) || (valueSpan && isWithin(position, valueSpan));
|
||||
if (!isWithinKeyValue) {
|
||||
// If cursor is within source span but not within key span or value span,
|
||||
// do not return the node.
|
||||
if (!isWithin(position, keySpan) && (valueSpan && !isWithin(position, valueSpan))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -504,8 +504,7 @@ describe('findNodeAtPosition for microsyntax expression', () => {
|
|||
const {errors, nodes, position} = parse(`<div *ngFor="l¦et item of items"></div>`);
|
||||
expect(errors).toBe(null);
|
||||
const node = findNodeAtPosition(nodes, position);
|
||||
// TODO: this is currently wrong because node is currently pointing to
|
||||
// "item". In this case, it should return undefined.
|
||||
expect(node).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should locate let variable', () => {
|
||||
|
|
Loading…
Reference in New Issue