diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 263ab35b200cf..6d23f64be662a 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -492,9 +492,7 @@ export function getDocCommentTemplateAtPosition(newLine: string, sourceFile: Sou // * if the caret was directly in front of the object, then we add an extra line and indentation. const openComment = "/**"; const closeComment = " */"; - - // If any of the existing jsDoc has tags, ignore adding new ones. - const hasTag = (commentOwnerJsDoc || []).some(jsDoc => !!jsDoc.tags); + const hasTag = length(getJSDocTags(commentOwner)) > 0; if (tags && !hasTag) { const preamble = openComment + newLine + indentationStr + " * "; diff --git a/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc.ts b/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc1.ts similarity index 100% rename from tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc.ts rename to tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc1.ts diff --git a/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc2.ts b/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc2.ts new file mode 100644 index 0000000000000..957b97b4001f8 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc2.ts @@ -0,0 +1,14 @@ +/// + +/////** @typedef {string} Id */ +//// +/////** /**/ */ +////function foo(x, y, z) {} + +verify.docCommentTemplateAt("", 7, +`/** + * + * @param x + * @param y + * @param z + */`); diff --git a/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc3.ts b/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc3.ts new file mode 100644 index 0000000000000..69ca0bd17c656 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateWithMultipleJSDoc3.ts @@ -0,0 +1,7 @@ +/// + +/////** @param p */ +/////*/**/ +////function foo(p) {} + +verify.docCommentTemplateAt("", 3, `/** */`); diff --git a/tests/cases/fourslash/docCommentTemplateWithMultipleJSDocAndParameters.ts b/tests/cases/fourslash/docCommentTemplateWithMultipleJSDocAndParameters.ts index add01b90006cf..a379352a103d0 100644 --- a/tests/cases/fourslash/docCommentTemplateWithMultipleJSDocAndParameters.ts +++ b/tests/cases/fourslash/docCommentTemplateWithMultipleJSDocAndParameters.ts @@ -9,4 +9,8 @@ /////*/**/ ////function foo(p) {} -verify.docCommentTemplateAt("", 3, "/** */"); +verify.docCommentTemplateAt("", 7, +`/** + * + * @param p + */`);