@@ -209,6 +209,11 @@ namespace ts.Completions {
209209 return { isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , entries } ;
210210 }
211211
212+ function getOptionalReplacementSpan ( location : Node | undefined ) {
213+ // StringLiteralLike locations are handled separately in stringCompletions.ts
214+ return location ?. kind === SyntaxKind . Identifier ? createTextSpanFromNode ( location ) : undefined ;
215+ }
216+
212217 function completionInfoFromData ( sourceFile : SourceFile , typeChecker : TypeChecker , compilerOptions : CompilerOptions , log : Log , completionData : CompletionData , preferences : UserPreferences ) : CompletionInfo | undefined {
213218 const {
214219 symbols,
@@ -241,7 +246,7 @@ namespace ts.Completions {
241246 kindModifiers : undefined ,
242247 sortText : SortText . LocationPriority ,
243248 } ;
244- return { isGlobalCompletion : false , isMemberCompletion : true , isNewIdentifierLocation : false , entries : [ entry ] } ;
249+ return { isGlobalCompletion : false , isMemberCompletion : true , isNewIdentifierLocation : false , optionalReplacementSpan : getOptionalReplacementSpan ( location ) , entries : [ entry ] } ;
245250 }
246251
247252 const entries : CompletionEntry [ ] = [ ] ;
@@ -305,7 +310,13 @@ namespace ts.Completions {
305310 entries . push ( createCompletionEntryForLiteral ( literal , preferences ) ) ;
306311 }
307312
308- return { isGlobalCompletion : isInSnippetScope , isMemberCompletion : isMemberCompletionKind ( completionKind ) , isNewIdentifierLocation, entries } ;
313+ return {
314+ isGlobalCompletion : isInSnippetScope ,
315+ isMemberCompletion : isMemberCompletionKind ( completionKind ) ,
316+ isNewIdentifierLocation,
317+ optionalReplacementSpan : getOptionalReplacementSpan ( location ) ,
318+ entries
319+ } ;
309320 }
310321
311322 function isUncheckedFile ( sourceFile : SourceFile , compilerOptions : CompilerOptions ) : boolean {
0 commit comments