When hovering over the LHS of an augmented assignment (e.g. the a within a += x), reveal the type of the symbol _after_ the operation rather than _before_.

This commit is contained in:
Eric Traut 2022-03-23 07:29:19 -06:00
parent 7d050c49bb
commit 8a69070892

View File

@ -95,6 +95,12 @@ export function findNodeByOffset(node: ParseNode, offset: number): ParseNode | u
if (child) {
const containingChild = findNodeByOffset(child, offset);
if (containingChild) {
// For augmented assignments, prefer the dest expression, which is a clone
// of the left expression but is used to hold the type of the operation result.
if (node.nodeType === ParseNodeType.AugmentedAssignment && containingChild === node.leftExpression) {
return node.destExpression;
}
return containingChild;
}
}