@@ -47,7 +47,7 @@ namespace ts.Completions {
47
47
return getLabelCompletionAtPosition ( contextToken . parent ) ;
48
48
}
49
49
50
- const completionData = getCompletionData ( program , log , sourceFile , position , preferences ) ;
50
+ const completionData = getCompletionData ( program , log , sourceFile , position , preferences , /*detailsEntryId*/ undefined ) ;
51
51
if ( ! completionData ) {
52
52
return undefined ;
53
53
}
@@ -486,9 +486,9 @@ namespace ts.Completions {
486
486
previousToken : Node ;
487
487
readonly isJsxInitializer : IsJsxInitializer ;
488
488
}
489
- function getSymbolCompletionFromEntryId ( program : Program , log : Log , sourceFile : SourceFile , position : number , { name , source } : CompletionEntryIdentifier ,
489
+ function getSymbolCompletionFromEntryId ( program : Program , log : Log , sourceFile : SourceFile , position : number , entryId : CompletionEntryIdentifier ,
490
490
) : SymbolCompletion | { type : "request" , request : Request } | { type : "none" } {
491
- const completionData = getCompletionData ( program , log , sourceFile , position , { includeCompletionsForModuleExports : true , includeCompletionsWithInsertText : true } ) ;
491
+ const completionData = getCompletionData ( program , log , sourceFile , position , { includeCompletionsForModuleExports : true , includeCompletionsWithInsertText : true } , entryId ) ;
492
492
if ( ! completionData ) {
493
493
return { type : "none" } ;
494
494
}
@@ -505,7 +505,9 @@ namespace ts.Completions {
505
505
return firstDefined < Symbol , SymbolCompletion > ( symbols , ( symbol ) : SymbolCompletion => { // TODO: Shouldn't need return type annotation (GH#12632)
506
506
const origin = symbolToOriginInfoMap [ getSymbolId ( symbol ) ] ;
507
507
const info = getCompletionEntryDisplayNameForSymbol ( symbol , program . getCompilerOptions ( ) . target , origin , completionKind ) ;
508
- return info && info . name === name && getSourceFromOrigin ( origin ) === source ? { type : "symbol" as "symbol" , symbol, location, symbolToOriginInfoMap, previousToken, isJsxInitializer } : undefined ;
508
+ return info && info . name === entryId . name && getSourceFromOrigin ( origin ) === entryId . source
509
+ ? { type : "symbol" as "symbol" , symbol, location, symbolToOriginInfoMap, previousToken, isJsxInitializer }
510
+ : undefined ;
509
511
} ) || { type : "none" } ;
510
512
}
511
513
@@ -755,6 +757,7 @@ namespace ts.Completions {
755
757
sourceFile : SourceFile ,
756
758
position : number ,
757
759
preferences : Pick < UserPreferences , "includeCompletionsForModuleExports" | "includeCompletionsWithInsertText" > ,
760
+ detailsEntryId : CompletionEntryIdentifier | undefined ,
758
761
) : CompletionData | Request | undefined {
759
762
const typeChecker = program . getTypeChecker ( ) ;
760
763
@@ -1302,6 +1305,11 @@ namespace ts.Completions {
1302
1305
const tokenTextLowerCase = tokenText . toLowerCase ( ) ;
1303
1306
1304
1307
codefix . forEachExternalModuleToImportFrom ( typeChecker , sourceFile , program . getSourceFiles ( ) , moduleSymbol => {
1308
+ // Perf -- ignore other modules if this is a request for details
1309
+ if ( detailsEntryId && detailsEntryId . source && stripQuotes ( moduleSymbol . name ) !== detailsEntryId . source ) {
1310
+ return ;
1311
+ }
1312
+
1305
1313
for ( let symbol of typeChecker . getExportsOfModule ( moduleSymbol ) ) {
1306
1314
// Don't add a completion for a re-export, only for the original.
1307
1315
// The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details.
@@ -1320,7 +1328,7 @@ namespace ts.Completions {
1320
1328
}
1321
1329
1322
1330
const origin : SymbolOriginInfo = { type : "export" , moduleSymbol, isDefaultExport } ;
1323
- if ( stringContainsCharactersInOrder ( getSymbolName ( symbol , origin , target ) . toLowerCase ( ) , tokenTextLowerCase ) ) {
1331
+ if ( detailsEntryId || stringContainsCharactersInOrder ( getSymbolName ( symbol , origin , target ) . toLowerCase ( ) , tokenTextLowerCase ) ) {
1324
1332
symbols . push ( symbol ) ;
1325
1333
symbolToOriginInfoMap [ getSymbolId ( symbol ) ] = origin ;
1326
1334
}
0 commit comments