Skip to content

Commit 8db251f

Browse files
authored
fix(52517): JSDoc Comment Template not provided when unrelated JSDoc with tag exists (#54132)
1 parent 8ea3887 commit 8db251f

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

src/services/jsDoc.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,7 @@ export function getDocCommentTemplateAtPosition(newLine: string, sourceFile: Sou
492492
// * if the caret was directly in front of the object, then we add an extra line and indentation.
493493
const openComment = "/**";
494494
const closeComment = " */";
495-
496-
// If any of the existing jsDoc has tags, ignore adding new ones.
497-
const hasTag = (commentOwnerJsDoc || []).some(jsDoc => !!jsDoc.tags);
495+
const hasTag = length(getJSDocTags(commentOwner)) > 0;
498496

499497
if (tags && !hasTag) {
500498
const preamble = openComment + newLine + indentationStr + " * ";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////** @typedef {string} Id */
4+
////
5+
/////** /**/ */
6+
////function foo(x, y, z) {}
7+
8+
verify.docCommentTemplateAt("", 7,
9+
`/**
10+
*
11+
* @param x
12+
* @param y
13+
* @param z
14+
*/`);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////** @param p */
4+
/////*/**/
5+
////function foo(p) {}
6+
7+
verify.docCommentTemplateAt("", 3, `/** */`);

tests/cases/fourslash/docCommentTemplateWithMultipleJSDocAndParameters.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
/////*/**/
1010
////function foo(p) {}
1111

12-
verify.docCommentTemplateAt("", 3, "/** */");
12+
verify.docCommentTemplateAt("", 7,
13+
`/**
14+
*
15+
* @param p
16+
*/`);

0 commit comments

Comments
 (0)