@@ -422,8 +422,9 @@ namespace ts.Completions {
422422 allSourceFiles : ReadonlyArray < SourceFile > ,
423423 host : LanguageServiceHost ,
424424 formatContext : formatting . FormatContext ,
425+ getCanonicalFileName : GetCanonicalFileName ,
425426 ) : CompletionEntryDetails {
426- const { name, source } = entryId ;
427+ const { name } = entryId ;
427428 // Compute all the completion symbols again.
428429 const symbolCompletion = getSymbolCompletionFromEntryId ( typeChecker , log , compilerOptions , sourceFile , position , entryId , allSourceFiles ) ;
429430 switch ( symbolCompletion . type ) {
@@ -442,10 +443,10 @@ namespace ts.Completions {
442443 }
443444 case "symbol" : {
444445 const { symbol, location, symbolToOriginInfoMap } = symbolCompletion ;
445- const codeActions = getCompletionEntryCodeActions ( symbolToOriginInfoMap , symbol , typeChecker , host , compilerOptions , sourceFile , formatContext ) ;
446+ const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay ( symbolToOriginInfoMap , symbol , typeChecker , host , compilerOptions , sourceFile , formatContext , getCanonicalFileName ) ;
446447 const kindModifiers = SymbolDisplay . getSymbolModifiers ( symbol ) ;
447448 const { displayParts, documentation, symbolKind, tags } = SymbolDisplay . getSymbolDisplayPartsDocumentationAndSymbolKind ( typeChecker , symbol , sourceFile , location , location , SemanticMeaning . All ) ;
448- return { name, kindModifiers, kind : symbolKind , displayParts, documentation, tags, codeActions, source : source === undefined ? undefined : [ textPart ( source ) ] } ;
449+ return { name, kindModifiers, kind : symbolKind , displayParts, documentation, tags, codeActions, source : sourceDisplay } ;
449450 }
450451 case "none" : {
451452 // Didn't find a symbol with this name. See if we can find a keyword instead.
@@ -466,33 +467,37 @@ namespace ts.Completions {
466467 }
467468 }
468469
469- function getCompletionEntryCodeActions (
470+ function getCompletionEntryCodeActionsAndSourceDisplay (
470471 symbolToOriginInfoMap : SymbolOriginInfoMap ,
471472 symbol : Symbol ,
472473 checker : TypeChecker ,
473474 host : LanguageServiceHost ,
474475 compilerOptions : CompilerOptions ,
475476 sourceFile : SourceFile ,
476477 formatContext : formatting . FormatContext ,
477- ) : CodeAction [ ] | undefined {
478+ getCanonicalFileName : GetCanonicalFileName ,
479+ ) : { codeActions : CodeAction [ ] | undefined , sourceDisplay : SymbolDisplayPart [ ] | undefined } {
478480 const symbolOriginInfo = symbolToOriginInfoMap [ getSymbolId ( symbol ) ] ;
479481 if ( ! symbolOriginInfo ) {
480- return undefined ;
482+ return { codeActions : undefined , sourceDisplay : undefined } ;
481483 }
482484
483485 const { moduleSymbol, isDefaultExport } = symbolOriginInfo ;
484- return codefix . getCodeActionForImport ( moduleSymbol , {
486+
487+ const sourceDisplay = [ textPart ( codefix . getModuleSpecifierForNewImport ( sourceFile , moduleSymbol , compilerOptions , getCanonicalFileName , host ) ) ] ;
488+ const codeActions = codefix . getCodeActionForImport ( moduleSymbol , {
485489 host,
486490 checker,
487491 newLineCharacter : host . getNewLine ( ) ,
488492 compilerOptions,
489493 sourceFile,
490494 formatContext,
491495 symbolName : getSymbolName ( symbol , symbolOriginInfo , compilerOptions . target ) ,
492- getCanonicalFileName : createGetCanonicalFileName ( host . useCaseSensitiveFileNames ? host . useCaseSensitiveFileNames ( ) : false ) ,
496+ getCanonicalFileName,
493497 symbolToken : undefined ,
494498 kind : isDefaultExport ? codefix . ImportKind . Default : codefix . ImportKind . Named ,
495499 } ) ;
500+ return { sourceDisplay, codeActions } ;
496501 }
497502
498503 export function getCompletionEntrySymbol (
0 commit comments