Skip to content

Commit cbc4b72

Browse files
committed
fix(server): return the right range for the original source file of DTS
When the user tries to go to the definition that is in the DTS file, the Angular LS will map it to the original source file. Because of not updating the `scriptInfo`, the Angular LS returns the wrong range of the definition.
1 parent 1ee183b commit cbc4b72

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/session.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,9 @@ export class Session {
930930
if (scriptInfo) {
931931
const project = this.getDefaultProjectForScriptInfo(scriptInfo);
932932
mappedInfo = project ? getMappedDefinitionInfo(d, project) : mappedInfo;
933-
range = tsTextSpanToLspRange(scriptInfo, mappedInfo.textSpan);
933+
// After the DTS file maps to original source file, the `scriptInfo` should be updated.
934+
const originalScriptInfo = this.projectService.getScriptInfo(mappedInfo.fileName) ?? scriptInfo;
935+
range = tsTextSpanToLspRange(originalScriptInfo, mappedInfo.textSpan);
934936
}
935937

936938
const targetUri = filePathToUri(mappedInfo.fileName);

0 commit comments

Comments
 (0)