Skip to content

Commit ce1164b

Browse files
committed
deep clone for each replacement
1 parent baec3fd commit ce1164b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/services/refactors/inlineVariable.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function getInliningInfo(file: SourceFile, startPosition: number, tryWithReferen
132132

133133
// Find all references to the variable in the current file.
134134
const references = getReferenceNodes(parent, checker, file);
135-
return references && { references, declaration: parent, replacement: getSynthesizedDeepClone(parent.initializer) };
135+
return references && { references, declaration: parent, replacement: parent.initializer };
136136
}
137137

138138
// Try finding the declaration and nodes to replace via the reference token.
@@ -148,7 +148,7 @@ function getInliningInfo(file: SourceFile, startPosition: number, tryWithReferen
148148
}
149149

150150
const references = getReferenceNodes(declaration, checker, file);
151-
return references && { references, declaration, replacement: getSynthesizedDeepClone(declaration.initializer) };
151+
return references && { references, declaration, replacement: declaration.initializer };
152152
}
153153

154154
return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
@@ -189,8 +189,8 @@ function getReplacementExpression(reference: Node, replacement: Expression): Exp
189189
// instead just check for special cases with needsParentheses.
190190
const { parent } = reference;
191191
if (isExpression(parent) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent) || needsParentheses(parent))) {
192-
return factory.createParenthesizedExpression(replacement);
192+
return getSynthesizedDeepClone(factory.createParenthesizedExpression(replacement));
193193
}
194194

195-
return replacement;
195+
return getSynthesizedDeepClone(replacement);
196196
}

0 commit comments

Comments
 (0)