Skip to content

Commit a3ab1ff

Browse files
authored
Merge pull request microsoft#20713 from amcasey/GH19165
Stop assuming code fix test changes are in the originating file
2 parents d89d68f + 8b09885 commit a3ab1ff

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/server/session.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ namespace ts.server {
12301230
return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source);
12311231
});
12321232
return simplifiedResult
1233-
? result.map(details => ({ ...details, codeActions: map(details.codeActions, action => this.mapCodeAction(action, scriptInfo)) }))
1233+
? result.map(details => ({ ...details, codeActions: map(details.codeActions, action => this.mapCodeAction(project, action)) }))
12341234
: result;
12351235
}
12361236

@@ -1560,7 +1560,7 @@ namespace ts.server {
15601560
return undefined;
15611561
}
15621562
if (simplifiedResult) {
1563-
return codeActions.map(codeAction => this.mapCodeAction(codeAction, scriptInfo));
1563+
return codeActions.map(codeAction => this.mapCodeAction(project, codeAction));
15641564
}
15651565
else {
15661566
return codeActions;
@@ -1613,8 +1613,8 @@ namespace ts.server {
16131613
return { startPosition, endPosition };
16141614
}
16151615

1616-
private mapCodeAction({ description, changes: unmappedChanges, commands }: CodeAction, scriptInfo: ScriptInfo): protocol.CodeAction {
1617-
const changes = unmappedChanges.map(change => this.mapTextChangesToCodeEditsUsingScriptinfo(change, scriptInfo));
1616+
private mapCodeAction(project: Project, { description, changes: unmappedChanges, commands }: CodeAction): protocol.CodeAction {
1617+
const changes = unmappedChanges.map(change => this.mapTextChangesToCodeEditsUsingScriptinfo(change, project.getScriptInfoForNormalizedPath(toNormalizedPath(change.fileName))));
16181618
return { description, changes, commands };
16191619
}
16201620

tests/baselines/reference/api/tsserverlibrary.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7092,7 +7092,7 @@ declare namespace ts.server {
70927092
private getCombinedCodeFix({scope, fixId}, simplifiedResult);
70937093
private applyCodeActionCommand(args);
70947094
private getStartAndEndPosition(args, scriptInfo);
7095-
private mapCodeAction({description, changes: unmappedChanges, commands}, scriptInfo);
7095+
private mapCodeAction(project, {description, changes: unmappedChanges, commands});
70967096
private mapTextChangesToCodeEdits(project, textChanges);
70977097
private mapTextChangesToCodeEditsUsingScriptinfo(textChanges, scriptInfo);
70987098
private convertTextChangeToCodeEdit(change, scriptInfo);

0 commit comments

Comments
 (0)