diff --git a/src/services/classifier.ts b/src/services/classifier.ts
index 1e1309a2eacf0..5d9b4924bed0c 100644
--- a/src/services/classifier.ts
+++ b/src/services/classifier.ts
@@ -771,6 +771,14 @@ namespace ts {
return false;
}
+ // Limiting classification to exactly the elements and attributes
+ // defined in `ts.commentPragmas` would be excessive, but we can avoid
+ // some obvious false positives (e.g. in XML-like doc comments) by
+ // checking the element name.
+ if (!match[3] || !(match[3] in commentPragmas)) {
+ return false;
+ }
+
let pos = start;
pushCommentRange(pos, match[1].length); // ///
@@ -779,10 +787,6 @@ namespace ts {
pushClassification(pos, match[2].length, ClassificationType.punctuation); // <
pos += match[2].length;
- if (!match[3]) {
- return true;
- }
-
pushClassification(pos, match[3].length, ClassificationType.jsxSelfClosingTagName); // element name
pos += match[3].length;
diff --git a/tests/cases/fourslash/syntacticClassificationsTripleSlash17.ts b/tests/cases/fourslash/syntacticClassificationsTripleSlash17.ts
new file mode 100644
index 0000000000000..b95cdd6b6c0f0
--- /dev/null
+++ b/tests/cases/fourslash/syntacticClassificationsTripleSlash17.ts
@@ -0,0 +1,7 @@
+///
+
+//// /// Text
+
+var c = classification;
+verify.syntacticClassificationsAre(
+ c.comment("/// Text"));
\ No newline at end of file
diff --git a/tests/cases/fourslash/syntacticClassificationsTripleSlash18.ts b/tests/cases/fourslash/syntacticClassificationsTripleSlash18.ts
new file mode 100644
index 0000000000000..148b17f6e4565
--- /dev/null
+++ b/tests/cases/fourslash/syntacticClassificationsTripleSlash18.ts
@@ -0,0 +1,7 @@
+///
+
+//// /// Text
+
+var c = classification;
+verify.syntacticClassificationsAre(
+ c.comment("/// Text"));
\ No newline at end of file
diff --git a/tests/cases/fourslash/syntacticClassificationsTripleSlash4.ts b/tests/cases/fourslash/syntacticClassificationsTripleSlash4.ts
index e656c81137743..d407bcee5032b 100644
--- a/tests/cases/fourslash/syntacticClassificationsTripleSlash4.ts
+++ b/tests/cases/fourslash/syntacticClassificationsTripleSlash4.ts
@@ -4,5 +4,4 @@
var c = classification;
verify.syntacticClassificationsAre(
- c.comment("/// "),
- c.punctuation("<"));
\ No newline at end of file
+ c.comment("/// <")); // Don't classify until we recognize the element name
\ No newline at end of file