Skip to content

Commit 3f1bb2d

Browse files
committed
Change to a version with minimal modifications
1 parent fe460f0 commit 3f1bb2d

File tree

3 files changed

+28
-135
lines changed

3 files changed

+28
-135
lines changed

src/services/completions.ts

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -852,34 +852,32 @@ namespace ts.Completions {
852852
let isInSnippetScope = false;
853853
if (insideComment) {
854854
if (hasDocComment(sourceFile, position)) {
855-
// When completion is requested without "@", we will have check to make sure that
856-
// there are no comments prefix the request position. We will only allow "*" and space.
857-
// e.g
858-
// /** |c| */
859-
//
860-
// /**
861-
// |c|
862-
// */
863-
//
864-
// /**
865-
// * |c|
866-
// */
867-
//
868-
// /**
869-
// * |c|
870-
// */
871-
const lineStart = getLineStartPositionForPosition(position, sourceFile);
872-
const jsdocFragment = sourceFile.text.substring(lineStart, position);
873-
const reJSDocFragment = /^(?:\s*\/\*\*\s+|\s+\*?\s+)(@(?:\w+)?)?/g;
874-
const match = reJSDocFragment.exec(jsdocFragment);
875-
if (match && reJSDocFragment.lastIndex === jsdocFragment.length) {
876-
return {
877-
kind: match[1]
878-
// The current position is next to the '@' sign, when no tag name being provided yet.
879-
// Provide a full list of tag names
880-
? CompletionDataKind.JsDocTagName
881-
: CompletionDataKind.JsDocTag
882-
};
855+
if (sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) {
856+
// The current position is next to the '@' sign, when no tag name being provided yet.
857+
// Provide a full list of tag names
858+
return { kind: CompletionDataKind.JsDocTagName };
859+
}
860+
else {
861+
// When completion is requested without "@", we will have check to make sure that
862+
// there are no comments prefix the request position. We will only allow "*" and space.
863+
// e.g
864+
// /** |c| /*
865+
//
866+
// /**
867+
// |c|
868+
// */
869+
//
870+
// /**
871+
// * |c|
872+
// */
873+
//
874+
// /**
875+
// * |c|
876+
// */
877+
const lineStart = getLineStartPositionForPosition(position, sourceFile);
878+
if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) {
879+
return { kind: CompletionDataKind.JsDocTag };
880+
}
883881
}
884882
}
885883

tests/cases/fourslash/completionInJsDoc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
//// /** /*9*/ */
3030
////
3131
//// /**
32-
//// /*10*/
33-
//// */
32+
//// /*10*/
33+
//// */
3434
////
3535
//// /**
3636
//// * /*11*/

tests/cases/fourslash/completionsJsdocTag.ts

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -5,109 +5,4 @@
55
//// * /**/
66
//// */
77

8-
9-
// 1x - jsdoc tags are listed when there is more than one whitespace after "*"
10-
/////**
11-
//// * /*10*/
12-
//// */
13-
////
14-
/////**
15-
//// * /*11*/
16-
//// */
17-
////
18-
19-
// 2x - Also, if there are two or more blanks at the beginning of the line
20-
/////**
21-
//// /*20*/
22-
//// */
23-
////
24-
/////**
25-
//// /*21*/
26-
//// */
27-
////
28-
29-
// 3x - jsdoc tag names will be listed
30-
/////** @/*30*/ */
31-
////
32-
/////** @/*31*/ */
33-
////
34-
/////**
35-
//// * @/*32*/
36-
//// */
37-
////
38-
/////**
39-
//// * @/*33*/
40-
//// */
41-
////
42-
/////**
43-
//// @/*34*/
44-
//// */
45-
////
46-
/////**
47-
//// @/*35*/
48-
//// */
49-
////
50-
/////**
51-
//// * @pa/*36*/
52-
//// */
53-
////
54-
55-
// 5x - jsdoc tag completions should not occur
56-
/////**
57-
//// */*50*/
58-
//// */
59-
////
60-
/////**
61-
//// /*51*/
62-
//// */
63-
////
64-
/////**
65-
/////*52*/
66-
//// */
67-
////
68-
698
verify.completions({ marker: "", includes: { name: "@property", text: "@property", kind: "keyword" } });
70-
71-
72-
//
73-
// test for src/services/completions.ts#getCompletionData.insideComment.hasDocComment (#37546)
74-
//
75-
test.markerNames().forEach(marker => {
76-
if (marker) {
77-
let completionOpt: FourSlashInterface.CompletionsOptions;
78-
const n = +marker;
79-
switch (n) {
80-
// jsdoc tags will be listed when there is more than one whitespace after "*"
81-
case 10: case 11:
82-
// Also, if there are two or more blanks at the beginning of the line
83-
case 20: case 21:
84-
completionOpt = { marker, includes: [
85-
"@abstract", "@access",
86-
]};
87-
break;
88-
89-
// 3x - jsdoc tag names will be listed
90-
case 30: case 31: case 32: case 33: case 34: case 35: case 36:
91-
completionOpt = {
92-
marker,
93-
triggerCharacter: "@",
94-
includes: ["package", "param"]
95-
};
96-
break;
97-
98-
// 5x - jsdoc tag completions should not occur
99-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100-
// before the fix, jsdoc tags was listed but no longer appears
101-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102-
case 50: case 51: case 52:
103-
completionOpt = { marker, exact: [] };
104-
break;
105-
106-
default:
107-
break;
108-
}
109-
if (completionOpt) {
110-
verify.completions(completionOpt);
111-
}
112-
}
113-
});

0 commit comments

Comments
 (0)