Skip to content

Commit c01afb5

Browse files
authored
fix(49548): show completions after keywords in block (microsoft#49600)
1 parent 7eddb3a commit c01afb5

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/services/completions.ts

+4
Original file line numberDiff line numberDiff line change
@@ -4094,6 +4094,10 @@ namespace ts.Completions {
40944094
}
40954095
break;
40964096
case SyntaxKind.Identifier: {
4097+
const originalKeywordKind = (location as Identifier).originalKeywordKind;
4098+
if (originalKeywordKind && isKeyword(originalKeywordKind)) {
4099+
return undefined;
4100+
}
40974101
// class c { public prop = c| }
40984102
if (isPropertyDeclaration(location.parent) && location.parent.initializer === location) {
40994103
return undefined;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////class C1 {
4+
//// method(map: Map<string, string>, key: string, defaultValue: string) {
5+
//// try {
6+
//// return map.get(key)!;
7+
//// }
8+
//// catch {
9+
//// return default/*1*/
10+
//// }
11+
//// }
12+
////}
13+
////class C2 {
14+
//// method(map: Map<string, string>, key: string, defaultValue: string) {
15+
//// if (map.has(key)) {
16+
//// return map.get(key)!;
17+
//// }
18+
//// else {
19+
//// return default/*2*/
20+
//// }
21+
//// }
22+
////}
23+
////class C3 {
24+
//// method(map: Map<string, string>, key: string, returnValue: string) {
25+
//// try {
26+
//// return map.get(key)!;
27+
//// }
28+
//// catch {
29+
//// return return/*3*/
30+
//// }
31+
//// }
32+
////}
33+
////class C4 {
34+
//// method(map: Map<string, string>, key: string, returnValue: string) {
35+
//// if (map.has(key)) {
36+
//// return map.get(key)!;
37+
//// }
38+
//// else {
39+
//// return return/*4*/
40+
//// }
41+
//// }
42+
////}
43+
44+
verify.completions({
45+
marker: ["1", "2"],
46+
includes: [{ name: "defaultValue", sortText: completion.SortText.LocationPriority }]
47+
}, {
48+
marker: ["3", "4"],
49+
includes: [{ name: "returnValue", sortText: completion.SortText.LocationPriority }]
50+
});

0 commit comments

Comments
 (0)