fix(49548): show completions after keywords in block (#49600)

This commit is contained in:
Oleksandr T 2022-06-20 22:52:28 +03:00 committed by GitHub
parent 7eddb3a122
commit c01afb5ef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 0 deletions

View File

@ -4094,6 +4094,10 @@ namespace ts.Completions {
}
break;
case SyntaxKind.Identifier: {
const originalKeywordKind = (location as Identifier).originalKeywordKind;
if (originalKeywordKind && isKeyword(originalKeywordKind)) {
return undefined;
}
// class c { public prop = c| }
if (isPropertyDeclaration(location.parent) && location.parent.initializer === location) {
return undefined;

View File

@ -0,0 +1,50 @@
/// <reference path="fourslash.ts" />
////class C1 {
//// method(map: Map<string, string>, key: string, defaultValue: string) {
//// try {
//// return map.get(key)!;
//// }
//// catch {
//// return default/*1*/
//// }
//// }
////}
////class C2 {
//// method(map: Map<string, string>, key: string, defaultValue: string) {
//// if (map.has(key)) {
//// return map.get(key)!;
//// }
//// else {
//// return default/*2*/
//// }
//// }
////}
////class C3 {
//// method(map: Map<string, string>, key: string, returnValue: string) {
//// try {
//// return map.get(key)!;
//// }
//// catch {
//// return return/*3*/
//// }
//// }
////}
////class C4 {
//// method(map: Map<string, string>, key: string, returnValue: string) {
//// if (map.has(key)) {
//// return map.get(key)!;
//// }
//// else {
//// return return/*4*/
//// }
//// }
////}
verify.completions({
marker: ["1", "2"],
includes: [{ name: "defaultValue", sortText: completion.SortText.LocationPriority }]
}, {
marker: ["3", "4"],
includes: [{ name: "returnValue", sortText: completion.SortText.LocationPriority }]
});