Skip to content

Commit

Permalink
fix(server): return the right range for the original source file of D…
Browse files Browse the repository at this point in the history
…TS (#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.
  • Loading branch information
ivanwonder authored Jan 27, 2022
1 parent 80d6985 commit 9a5ecd9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9a5ecd9

Please sign in to comment.