Skip to content

Commit 90b6f0a

Browse files
committed
update forslash test
breaking changes fourslash test Temporarily retain the before fix code for easy comparison
1 parent 187c28a commit 90b6f0a

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

src/services/completions.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ namespace ts.Completions {
855855
// When completion is requested without "@", we will have check to make sure that
856856
// there are no comments prefix the request position. We will only allow "*" and space.
857857
// e.g
858-
// /** |c| /*
858+
// /** |c| */
859859
//
860860
// /**
861861
// |c|
@@ -868,6 +868,19 @@ namespace ts.Completions {
868868
// /**
869869
// * |c|
870870
// */
871+
/* https://coderwall.com/p/zbc2zw/the-comment-toggle-trick
872+
if (sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) {
873+
// The current position is next to the '@' sign, when no tag name being provided yet.
874+
// Provide a full list of tag names
875+
return { kind: CompletionDataKind.JsDocTagName };
876+
}
877+
else {
878+
const lineStart = getLineStartPositionForPosition(position, sourceFile);
879+
if (!(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/))) {
880+
return { kind: CompletionDataKind.JsDocTag };
881+
}
882+
}
883+
/*/
871884
const lineStart = getLineStartPositionForPosition(position, sourceFile);
872885
// jsdoc tag will be listed if there is more than one whitespace after "*"
873886
const match = /^\s*(?:[*\s]+(?=\s)|\/\*\*)?\s+(@)?$/.exec(
@@ -880,6 +893,7 @@ namespace ts.Completions {
880893
kind: match[1] ? CompletionDataKind.JsDocTagName: CompletionDataKind.JsDocTag
881894
};
882895
}
896+
//*/
883897
}
884898

885899
// Completion should work inside certain JsDoc tags. For example:

tests/cases/fourslash/completionsJsdocTag.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,64 @@
1111
////function a0(s: string) {}
1212
////
1313

14+
/////**@/*2*/ */
15+
////const some = 0;
16+
////
17+
1418
verify.completions({ marker: "", includes: { name: "@property", text: "@property", kind: "keyword" } });
1519

1620

1721
//
1822
// test for src/services/completions.ts#getCompletionData.insideComment.hasDocComment (#37546)
1923
//
24+
goTo.marker("2");
25+
// line 1: [/**@|c|]
26+
// before the fix, jsdoc tag names was listed (but no longer appears
27+
// jsdoc tag names are still listed after the fix.
28+
// 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|]
34+
// before the fix, jsdoc tags was listed but no longer appears
35+
edit.backspace(1);
36+
verify.completions({
37+
exact: []
38+
});
39+
40+
goTo.marker("1");
2041
// line 2: [ +|c|]
2142
verify.completions({
22-
marker: "1",
43+
// marker: "1",
2344
exact: []
2445
});
2546
// line 2: [ +|c|] -> [ +@|c|]
2647
// before the fix, jsdoc tag names was listed but no longer appears
2748
edit.insert("@");
2849
verify.completions({
29-
marker: "1",
50+
// marker: "1", // marker is invalid
51+
triggerCharacter: "@",
52+
exact: []
53+
});
54+
55+
// line 2: [ +@|c|] -> [ * ### jsdoc @|c|]
56+
// before the fix, jsdoc tag names was listed but no longer appears
57+
edit.replaceLine(1, " * ### jsdoc @");
58+
verify.completions({
59+
triggerCharacter: "@",
3060
exact: []
3161
});
62+
3263
// line 2: [ +@|c|] -> [ *|c|]
3364
// before the fix, jsdoc tags was listed but no longer appears
3465
edit.replaceLine(1, " *");
3566
verify.completions({
3667
exact: []
3768
});
69+
3870
// line 2: [ *|c|] -> [ *@|c|]
39-
// this behavior does not by getCompletionData.insideComment.hasDocComment section
71+
// this behavior does not by getCompletionData.insideComment.hasDocComment clause
4072
edit.insert("@");
4173
verify.completions({
4274
triggerCharacter: "@",

0 commit comments

Comments
 (0)