Skip to content

Commit a0160dd

Browse files
committed
regex
1 parent 90b6f0a commit a0160dd

File tree

2 files changed

+81
-68
lines changed

2 files changed

+81
-68
lines changed

src/services/completions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ namespace ts.Completions {
883883
/*/
884884
const lineStart = getLineStartPositionForPosition(position, sourceFile);
885885
// jsdoc tag will be listed if there is more than one whitespace after "*"
886-
const match = /^\s*(?:[*\s]+(?=\s)|\/\*\*)?\s+(@)?$/.exec(
886+
const match = /^(?:\s*\/\*\*|[*\s]+(?=\s))?\s+(@)?$/.exec(
887887
sourceFile.text.substring(lineStart, position)
888888
);
889889
if (match) {

tests/cases/fourslash/completionsJsdocTag.ts

+80-67
Original file line numberDiff line numberDiff line change
@@ -5,85 +5,98 @@
55
//// * /**/
66
//// */
77

8+
9+
// jsdoc tags are listed when there is more than one whitespace after "*"
810
/////**
9-
//// +/*1*/
11+
//// * /*1*/
1012
//// */
11-
////function a0(s: string) {}
1213
////
13-
14-
/////**@/*2*/ */
15-
////const some = 0;
14+
/////**
15+
//// * link to {/*2*/
16+
//// */
1617
////
1718

18-
verify.completions({ marker: "", includes: { name: "@property", text: "@property", kind: "keyword" } });
19-
20-
21-
//
22-
// test for src/services/completions.ts#getCompletionData.insideComment.hasDocComment (#37546)
23-
//
24-
goTo.marker("2");
25-
// line 1: [/**@|c|]
2619
// before the fix, jsdoc tag names was listed (but no longer appears
2720
// jsdoc tag names are still listed after the fix.
2821
// however this behavior does not by getCompletionData.insideComment.hasDocComment clause
29-
verify.completions({
30-
triggerCharacter: "@",
31-
includes: ["abstract", "access"]
32-
});
33-
// line 1: [/**@|c|] -> [/**|c|]
22+
/////**@/*3*/ */
23+
////
24+
/////**
25+
//// * @type {@/*4*/
26+
//// */
27+
////
28+
/////**
29+
//// *@/*5*/
30+
//// */
31+
////
32+
3433
// before the fix, jsdoc tags was listed but no longer appears
35-
edit.backspace(1);
36-
verify.completions({
37-
exact: []
38-
});
34+
/////**
35+
//// +/*6*/
36+
//// */
37+
////
38+
/////**
39+
//// */*7*/
40+
//// */
41+
////
3942

40-
goTo.marker("1");
41-
// line 2: [ +|c|]
42-
verify.completions({
43-
// marker: "1",
44-
exact: []
45-
});
46-
// line 2: [ +|c|] -> [ +@|c|]
47-
// before the fix, jsdoc tag names was listed but no longer appears
48-
edit.insert("@");
49-
verify.completions({
50-
// marker: "1", // marker is invalid
51-
triggerCharacter: "@",
52-
exact: []
53-
});
43+
// jsdoc tag names will be listed
44+
/////**
45+
//// * @/*8*/
46+
//// */
47+
////
5448

55-
// line 2: [ +@|c|] -> [ * ### jsdoc @|c|]
5649
// before the fix, jsdoc tag names was listed but no longer appears
57-
edit.replaceLine(1, " * ### jsdoc @");
58-
verify.completions({
59-
triggerCharacter: "@",
60-
exact: []
61-
});
50+
/////**
51+
//// +@/*9*/
52+
//// */
53+
////
54+
/////**
55+
//// * ### jsdoc @/*10*/
56+
//// */
57+
////
6258

63-
// line 2: [ +@|c|] -> [ *|c|]
64-
// before the fix, jsdoc tags was listed but no longer appears
65-
edit.replaceLine(1, " *");
66-
verify.completions({
67-
exact: []
68-
});
59+
verify.completions({ marker: "", includes: { name: "@property", text: "@property", kind: "keyword" } });
6960

70-
// line 2: [ *|c|] -> [ *@|c|]
71-
// this behavior does not by getCompletionData.insideComment.hasDocComment clause
72-
edit.insert("@");
73-
verify.completions({
74-
triggerCharacter: "@",
75-
includes: ["abstract", "access"]
76-
});
77-
// line 2: [ *@|c|] -> [ * |c|]
78-
// jsdoc tags are listed when there is more than one whitespace after "*"
79-
edit.replaceLine(1, " * ");
80-
verify.completions({
81-
includes: ["@abstract", "@access"]
82-
});
83-
// line 2: [ * |c|] -> [ * @|c|]
84-
// jsdoc tag names will be listed
85-
edit.insert("@");
86-
verify.completions({
87-
triggerCharacter: "@",
88-
includes: ["abstract", "access"]
61+
62+
//
63+
// test for src/services/completions.ts#getCompletionData.insideComment.hasDocComment (#37546)
64+
//
65+
test.markerNames().forEach(marker => {
66+
if (marker) {
67+
const n = +marker;
68+
switch (n) {
69+
case 1:
70+
// case 2:
71+
verify.completions({ marker, includes: ["@abstract", "@access"] });
72+
break;
73+
case 3:
74+
// case 4:
75+
case 5:
76+
verify.completions({
77+
marker,
78+
triggerCharacter: "@",
79+
includes: ["abstract", "access"]
80+
});
81+
break;
82+
case 6: case 7:
83+
verify.completions({ marker, exact: [] });
84+
break;
85+
case 8:
86+
verify.completions({
87+
marker,
88+
triggerCharacter: "@",
89+
includes: ["abstract", "access"]
90+
});
91+
break;
92+
case 9: case 10:
93+
verify.completions({
94+
marker,
95+
triggerCharacter: "@",
96+
exact: []
97+
});
98+
break;
99+
default: break;
100+
}
101+
}
89102
});

0 commit comments

Comments
 (0)