@@ -16,11 +16,11 @@ namespace ts.Completions {
1616 return undefined ;
1717 }
1818
19- const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData ;
19+ const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName } = completionData ;
2020
2121 if ( isJsDocTagName ) {
2222 // If the current position is a jsDoc tag name, only tag names should be provided for completion
23- return { isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , entries : JsDoc . getAllJsDocCompletionEntries ( ) } ;
23+ return { isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , entries : JsDoc . getAllJsDocCompletionEntries ( shouldAppendAtSignBeforeJsDocTagName ) } ;
2424 }
2525
2626 const entries : CompletionEntry [ ] = [ ] ;
@@ -815,6 +815,12 @@ namespace ts.Completions {
815815 const isJavaScriptFile = isSourceFileJavaScript ( sourceFile ) ;
816816
817817 let isJsDocTagName = false ;
818+ // This is for the case when users request completion in JsDoc without "@"
819+ // i.e.
820+ // /**
821+ // * |completion here|
822+ // **/
823+ let shouldAppendAtSignBeforeJsDocTagName = false ;
818824
819825 let start = timestamp ( ) ;
820826 const currentToken = getTokenAtPosition ( sourceFile , position ) ;
@@ -826,10 +832,24 @@ namespace ts.Completions {
826832 log ( "getCompletionData: Is inside comment: " + ( timestamp ( ) - start ) ) ;
827833
828834 if ( insideComment ) {
829- // The current position is next to the '@' sign, when no tag name being provided yet.
830- // Provide a full list of tag names
831- if ( hasDocComment ( sourceFile , position ) && sourceFile . text . charCodeAt ( position - 1 ) === CharacterCodes . at ) {
832- isJsDocTagName = true ;
835+ if ( hasDocComment ( sourceFile , position ) ) {
836+ // The current position is next to the '@' sign, when no tag name being provided yet.
837+ // Provide a full list of tag names
838+ if ( sourceFile . text . charCodeAt ( position - 1 ) === CharacterCodes . at ) {
839+ isJsDocTagName = true ;
840+ }
841+ else {
842+ const lineStart = getLineStartPositionForPosition ( position , sourceFile ) ;
843+ shouldAppendAtSignBeforeJsDocTagName = sourceFile . text . substr ( lineStart , position ) . indexOf ( "@" ) === - 1 ;
844+
845+ // This is for the case
846+ // /**
847+ // * |completion here|
848+ // **/
849+ if ( shouldAppendAtSignBeforeJsDocTagName ) {
850+ isJsDocTagName = true ;
851+ }
852+ }
833853 }
834854
835855 // Completion should work inside certain JsDoc tags. For example:
@@ -854,8 +874,8 @@ namespace ts.Completions {
854874 }
855875 }
856876
857- if ( isJsDocTagName ) {
858- return { symbols : undefined , isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , location : undefined , isRightOfDot : false , isJsDocTagName } ;
877+ if ( isJsDocTagName || shouldAppendAtSignBeforeJsDocTagName ) {
878+ return { symbols : undefined , isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , location : undefined , isRightOfDot : false , isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName } ;
859879 }
860880
861881 if ( ! insideJsDocTagExpression ) {
@@ -983,7 +1003,7 @@ namespace ts.Completions {
9831003
9841004 log ( "getCompletionData: Semantic work: " + ( timestamp ( ) - semanticStart ) ) ;
9851005
986- return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot : ( isRightOfDot || isRightOfOpenTag ) , isJsDocTagName } ;
1006+ return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot : ( isRightOfDot || isRightOfOpenTag ) , isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName } ;
9871007
9881008 function getTypeScriptMemberSymbols ( ) : void {
9891009 // Right of dot member completion list
0 commit comments