Skip to content

Commit 5e38082

Browse files
authored
fix(47165): ignore spaces in goToDefinition imports (#47541)
1 parent 5e09e86 commit 5e38082

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

src/services/goToDefinition.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ namespace ts.GoToDefinition {
171171
}
172172

173173
if (sourceFile.resolvedModules?.size()) {
174-
const node = getTokenAtPosition(sourceFile, position);
174+
const node = getTouchingToken(sourceFile, position);
175175
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, getModeForUsageLocation(sourceFile, node))) {
176176
const verifiedFileName = sourceFile.resolvedModules.get(node.text, getModeForUsageLocation(sourceFile, node))?.resolvedFileName;
177177
const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// @Filename: /b.ts
4+
/////*2*/export const foo = 1;
5+
6+
// @Filename: /a.ts
7+
////import { foo } from [|"./b/*1*/"|];
8+
9+
verify.goToDefinition("1", "2");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// @Filename: /b.ts
4+
/////*2*/export const foo = 1;
5+
6+
// @Filename: /a.ts
7+
////import { foo } [|from/*1*/|] "./b";
8+
9+
verify.goToDefinition("1", []);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// @Filename: /b.ts
4+
/////*2*/export const foo = 1;
5+
6+
// @Filename: /a.ts
7+
////import { foo } [|from /*1*/|] "./b";
8+
9+
verify.goToDefinition("1", []);

0 commit comments

Comments
 (0)