@@ -2847,7 +2847,7 @@ function getCompletionEntryCodeActionsAndSourceDisplay(
2847
2847
cancellationToken : CancellationToken ,
2848
2848
) : CodeActionsAndSourceDisplay {
2849
2849
if ( data ?. moduleSpecifier ) {
2850
- if ( previousToken && getImportStatementCompletionInfo ( contextToken || previousToken ) . replacementSpan ) {
2850
+ if ( previousToken && getImportStatementCompletionInfo ( contextToken || previousToken , sourceFile ) . replacementSpan ) {
2851
2851
// Import statement completion: 'import c|'
2852
2852
return { codeActions : undefined , sourceDisplay : [ textPart ( data . moduleSpecifier ) ] } ;
2853
2853
}
@@ -3176,7 +3176,7 @@ function getCompletionData(
3176
3176
let flags = CompletionInfoFlags . None ;
3177
3177
3178
3178
if ( contextToken ) {
3179
- const importStatementCompletionInfo = getImportStatementCompletionInfo ( contextToken ) ;
3179
+ const importStatementCompletionInfo = getImportStatementCompletionInfo ( contextToken , sourceFile ) ;
3180
3180
if ( importStatementCompletionInfo . keywordCompletion ) {
3181
3181
if ( importStatementCompletionInfo . isKeywordOnlyCompletion ) {
3182
3182
return {
@@ -5469,7 +5469,7 @@ export interface ImportStatementCompletionInfo {
5469
5469
replacementSpan : TextSpan | undefined ;
5470
5470
}
5471
5471
5472
- function getImportStatementCompletionInfo ( contextToken : Node ) : ImportStatementCompletionInfo {
5472
+ function getImportStatementCompletionInfo ( contextToken : Node , sourceFile : SourceFile ) : ImportStatementCompletionInfo {
5473
5473
let keywordCompletion : TokenSyntaxKind | undefined ;
5474
5474
let isKeywordOnlyCompletion = false ;
5475
5475
const candidate = getCandidate ( ) ;
@@ -5485,6 +5485,15 @@ function getImportStatementCompletionInfo(contextToken: Node): ImportStatementCo
5485
5485
function getCandidate ( ) {
5486
5486
const parent = contextToken . parent ;
5487
5487
if ( isImportEqualsDeclaration ( parent ) ) {
5488
+ // import Foo |
5489
+ // import Foo f|
5490
+ const lastToken = parent . getLastToken ( sourceFile ) ;
5491
+ if ( isIdentifier ( contextToken ) && lastToken !== contextToken ) {
5492
+ keywordCompletion = SyntaxKind . FromKeyword ;
5493
+ isKeywordOnlyCompletion = true ;
5494
+ return undefined ;
5495
+ }
5496
+
5488
5497
keywordCompletion = contextToken . kind === SyntaxKind . TypeKeyword ? undefined : SyntaxKind . TypeKeyword ;
5489
5498
return isModuleSpecifierMissingOrEmpty ( parent . moduleReference ) ? parent : undefined ;
5490
5499
}
0 commit comments