@@ -16,11 +16,11 @@ namespace ts.Completions {
16
16
return undefined ;
17
17
}
18
18
19
- const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData ;
19
+ const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName } = completionData ;
20
20
21
21
if ( isJsDocTagName ) {
22
22
// 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 ) } ;
24
24
}
25
25
26
26
const entries : CompletionEntry [ ] = [ ] ;
@@ -815,6 +815,12 @@ namespace ts.Completions {
815
815
const isJavaScriptFile = isSourceFileJavaScript ( sourceFile ) ;
816
816
817
817
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 ;
818
824
819
825
let start = timestamp ( ) ;
820
826
const currentToken = getTokenAtPosition ( sourceFile , position ) ;
@@ -826,10 +832,24 @@ namespace ts.Completions {
826
832
log ( "getCompletionData: Is inside comment: " + ( timestamp ( ) - start ) ) ;
827
833
828
834
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
+ }
833
853
}
834
854
835
855
// Completion should work inside certain JsDoc tags. For example:
@@ -854,8 +874,8 @@ namespace ts.Completions {
854
874
}
855
875
}
856
876
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 } ;
859
879
}
860
880
861
881
if ( ! insideJsDocTagExpression ) {
@@ -983,7 +1003,7 @@ namespace ts.Completions {
983
1003
984
1004
log ( "getCompletionData: Semantic work: " + ( timestamp ( ) - semanticStart ) ) ;
985
1005
986
- return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot : ( isRightOfDot || isRightOfOpenTag ) , isJsDocTagName } ;
1006
+ return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot : ( isRightOfDot || isRightOfOpenTag ) , isJsDocTagName, shouldAppendAtSignBeforeJsDocTagName } ;
987
1007
988
1008
function getTypeScriptMemberSymbols ( ) : void {
989
1009
// Right of dot member completion list
0 commit comments