File tree 3 files changed +30
-3
lines changed 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -357,8 +357,12 @@ namespace ts.JsDoc {
357
357
}
358
358
359
359
const { commentOwner, parameters, hasReturn } = commentOwnerInfo ;
360
- const commentOwnerJSDoc = hasJSDocNodes ( commentOwner ) && commentOwner . jsDoc ? lastOrUndefined ( commentOwner . jsDoc ) : undefined ;
361
- if ( commentOwner . getStart ( sourceFile ) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment ) {
360
+ const commentOwnerJsDoc = hasJSDocNodes ( commentOwner ) && commentOwner . jsDoc ? commentOwner . jsDoc : undefined ;
361
+ const lastJsDoc = lastOrUndefined ( commentOwnerJsDoc ) ;
362
+ if ( commentOwner . getStart ( sourceFile ) < position
363
+ || lastJsDoc
364
+ && existingDocComment
365
+ && lastJsDoc !== existingDocComment ) {
362
366
return undefined ;
363
367
}
364
368
@@ -378,7 +382,11 @@ namespace ts.JsDoc {
378
382
// * if the caret was directly in front of the object, then we add an extra line and indentation.
379
383
const openComment = "/**" ;
380
384
const closeComment = " */" ;
381
- if ( tags ) {
385
+
386
+ // If any of the existing jsDoc has tags, ignore adding new ones.
387
+ const hasTag = ( commentOwnerJsDoc || [ ] ) . some ( jsDoc => ! ! jsDoc . tags ) ;
388
+
389
+ if ( tags && ! hasTag ) {
382
390
const preamble = openComment + newLine + indentationStr + " * " ;
383
391
const endLine = tokenStart === position ? newLine + indentationStr : "" ;
384
392
const result = preamble + newLine + tags + indentationStr + closeComment + endLine ;
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ /////** */
4
+ /////*/**/
5
+ ////function foo() {}
6
+
7
+ verify . docCommentTemplateAt ( "" , 3 , "/** */" ) ;
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ /////** */
4
+ /////**
5
+ //// *
6
+ //// * @param p
7
+ //// */
8
+ /////** */
9
+ /////*/**/
10
+ ////function foo(p) {}
11
+
12
+ verify . docCommentTemplateAt ( "" , 3 , "/** */" ) ;
You can’t perform that action at this time.
0 commit comments