From 9a5ecd92cf617259e474fc23461cb586cc6ead76 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 Jan 2022 04:57:22 +0800 Subject: [PATCH] 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. --- server/src/session.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/session.ts b/server/src/session.ts index ae77576d2b..a8d970c8a0 100644 --- a/server/src/session.ts +++ b/server/src/session.ts @@ -930,7 +930,10 @@ export class Session { if (scriptInfo) { const project = this.getDefaultProjectForScriptInfo(scriptInfo); mappedInfo = project ? getMappedDefinitionInfo(d, project) : mappedInfo; - range = tsTextSpanToLspRange(scriptInfo, mappedInfo.textSpan); + // After the DTS file maps to original source file, the `scriptInfo` should be updated. + const originalScriptInfo = + this.projectService.getScriptInfo(mappedInfo.fileName) ?? scriptInfo; + range = tsTextSpanToLspRange(originalScriptInfo, mappedInfo.textSpan); } const targetUri = filePathToUri(mappedInfo.fileName);