Skip to content

Commit 9a5ecd9

Browse files
authored
fix(server): return the right range for the original source file of DTS (#1604)
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 80d6985 commit 9a5ecd9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/src/session.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,10 @@ 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 =
935+
this.projectService.getScriptInfo(mappedInfo.fileName) ?? scriptInfo;
936+
range = tsTextSpanToLspRange(originalScriptInfo, mappedInfo.textSpan);
934937
}
935938

936939
const targetUri = filePathToUri(mappedInfo.fileName);

0 commit comments

Comments
 (0)