@@ -682,6 +682,14 @@ function resolvingModuleSpecifiers<TReturn>(
682682 }
683683}
684684
685+ /** @internal */
686+ export function getDefaultCommitCharacters ( isNewIdentifierLocation : boolean ) : string [ ] {
687+ if ( isNewIdentifierLocation ) {
688+ return [ ] ;
689+ }
690+ return [ "." , "," , ";" ] ;
691+ }
692+
685693/** @internal */
686694export function getCompletionsAtPosition (
687695 host : LanguageServiceHost ,
@@ -704,7 +712,14 @@ export function getCompletionsAtPosition(
704712 if ( triggerCharacter === " " ) {
705713 // `isValidTrigger` ensures we are at `import |`
706714 if ( preferences . includeCompletionsForImportStatements && preferences . includeCompletionsWithInsertText ) {
707- return { isGlobalCompletion : true , isMemberCompletion : false , isNewIdentifierLocation : true , isIncomplete : true , entries : [ ] } ;
715+ return {
716+ isGlobalCompletion : true ,
717+ isMemberCompletion : false ,
718+ isNewIdentifierLocation : true ,
719+ isIncomplete : true ,
720+ entries : [ ] ,
721+ defaultCommitCharacters : getDefaultCommitCharacters ( /*isNewIdentifierLocation*/ true ) ,
722+ } ;
708723 }
709724 return undefined ;
710725 }
@@ -887,7 +902,13 @@ function continuePreviousIncompleteResponse(
887902}
888903
889904function jsdocCompletionInfo ( entries : CompletionEntry [ ] ) : CompletionInfo {
890- return { isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , entries } ;
905+ return {
906+ isGlobalCompletion : false ,
907+ isMemberCompletion : false ,
908+ isNewIdentifierLocation : false ,
909+ entries,
910+ defaultCommitCharacters : getDefaultCommitCharacters ( /*isNewIdentifierLocation*/ false ) ,
911+ } ;
891912}
892913
893914function getJSDocParameterCompletions (
@@ -1212,6 +1233,7 @@ function specificKeywordCompletionInfo(entries: readonly CompletionEntry[], isNe
12121233 isMemberCompletion : false ,
12131234 isNewIdentifierLocation,
12141235 entries : entries . slice ( ) ,
1236+ defaultCommitCharacters : getDefaultCommitCharacters ( isNewIdentifierLocation ) ,
12151237 } ;
12161238}
12171239
@@ -1387,6 +1409,7 @@ function completionInfoFromData(
13871409 isNewIdentifierLocation,
13881410 optionalReplacementSpan : getOptionalReplacementSpan ( location ) ,
13891411 entries,
1412+ defaultCommitCharacters : getDefaultCommitCharacters ( isNewIdentifierLocation ) ,
13901413 } ;
13911414}
13921415
@@ -1596,7 +1619,14 @@ function getJsxClosingTagCompletion(location: Node | undefined, sourceFile: Sour
15961619 kindModifiers : undefined ,
15971620 sortText : SortText . LocationPriority ,
15981621 } ;
1599- return { isGlobalCompletion : false , isMemberCompletion : true , isNewIdentifierLocation : false , optionalReplacementSpan : replacementSpan , entries : [ entry ] } ;
1622+ return {
1623+ isGlobalCompletion : false ,
1624+ isMemberCompletion : true ,
1625+ isNewIdentifierLocation : false ,
1626+ optionalReplacementSpan : replacementSpan ,
1627+ entries : [ entry ] ,
1628+ defaultCommitCharacters : getDefaultCommitCharacters ( /*isNewIdentifierLocation*/ false ) ,
1629+ } ;
16001630 }
16011631 return ;
16021632}
@@ -1622,6 +1652,7 @@ function getJSCompletionEntries(
16221652 kindModifiers : "" ,
16231653 sortText : SortText . JavascriptIdentifiers ,
16241654 isFromUncheckedFile : true ,
1655+ commitCharacters : [ ] ,
16251656 } , compareCompletionEntries ) ;
16261657 }
16271658 } ) ;
@@ -1633,7 +1664,13 @@ function completionNameForLiteral(sourceFile: SourceFile, preferences: UserPrefe
16331664}
16341665
16351666function createCompletionEntryForLiteral ( sourceFile : SourceFile , preferences : UserPreferences , literal : string | number | PseudoBigInt ) : CompletionEntry {
1636- return { name : completionNameForLiteral ( sourceFile , preferences , literal ) , kind : ScriptElementKind . string , kindModifiers : ScriptElementKindModifier . none , sortText : SortText . LocationPriority } ;
1667+ return {
1668+ name : completionNameForLiteral ( sourceFile , preferences , literal ) ,
1669+ kind : ScriptElementKind . string ,
1670+ kindModifiers : ScriptElementKindModifier . none ,
1671+ sortText : SortText . LocationPriority ,
1672+ commitCharacters : [ ] ,
1673+ } ;
16371674}
16381675
16391676function createCompletionEntry (
@@ -1863,9 +1900,11 @@ function createCompletionEntry(
18631900
18641901 // Use a 'sortText' of 0' so that all symbol completion entries come before any other
18651902 // entries (like JavaScript identifier entries).
1903+ const kind = SymbolDisplay . getSymbolKind ( typeChecker , symbol , location ) ;
1904+ const commitCharacters = ( kind === ScriptElementKind . warning || kind === ScriptElementKind . string ) ? [ ] : undefined ;
18661905 return {
18671906 name,
1868- kind : SymbolDisplay . getSymbolKind ( typeChecker , symbol , location ) ,
1907+ kind,
18691908 kindModifiers : SymbolDisplay . getSymbolModifiers ( typeChecker , symbol ) ,
18701909 sortText,
18711910 source,
@@ -1880,6 +1919,7 @@ function createCompletionEntry(
18801919 isPackageJsonImport : originIsPackageJsonImport ( origin ) || undefined ,
18811920 isImportStatementCompletion : ! ! importStatementCompletion || undefined ,
18821921 data,
1922+ commitCharacters,
18831923 ...includeSymbol ? { symbol } : undefined ,
18841924 } ;
18851925}
@@ -2754,7 +2794,13 @@ export function getCompletionEntriesFromSymbols(
27542794function getLabelCompletionAtPosition ( node : BreakOrContinueStatement ) : CompletionInfo | undefined {
27552795 const entries = getLabelStatementCompletions ( node ) ;
27562796 if ( entries . length ) {
2757- return { isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , entries } ;
2797+ return {
2798+ isGlobalCompletion : false ,
2799+ isMemberCompletion : false ,
2800+ isNewIdentifierLocation : false ,
2801+ entries,
2802+ defaultCommitCharacters : getDefaultCommitCharacters ( /*isNewIdentifierLocation*/ false ) ,
2803+ } ;
27582804 }
27592805}
27602806
0 commit comments