Skip to content

Commit b70118f

Browse files
committed
fix: apply completions for unclosed literal and missing comma
1 parent 00dcdd6 commit b70118f

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed

src/services/completions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ namespace ts.Completions {
18951895

18961896
// Check completions for Object property value shorthand
18971897
if (instantiatedType === undefined) {
1898-
if (objectLikeContainer.flags & (NodeFlags.ThisNodeHasError | NodeFlags.InWithStatement)) {
1898+
if (objectLikeContainer.flags & NodeFlags.InWithStatement) {
18991899
return GlobalsSearch.Fail;
19001900
}
19011901
return GlobalsSearch.Continue;
@@ -2326,6 +2326,7 @@ namespace ts.Completions {
23262326
}
23272327

23282328
return isDeclarationName(contextToken)
2329+
&& !isShorthandPropertyAssignment(contextToken.parent)
23292330
&& !isJsxAttribute(contextToken.parent)
23302331
// Don't block completions if we're in `class C /**/`, because we're *past* the end of the identifier and might want to complete `extends`.
23312332
// If `contextToken !== previousToken`, this is `class C ex/**/`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
//// const foo = 1;
4+
//// const bar = 2;
5+
6+
//// const obj1 = {
7+
//// foo b/*1*/
8+
//// };
9+
10+
//// const obj2: any = {
11+
//// foo b/*2*/
12+
//// };
13+
14+
verify.completions({
15+
marker: test.markers(),
16+
includes: ["bar"]
17+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
//// const foo = 1;
4+
//// const bar = 2;
5+
//// const obj = {
6+
//// foo b/*1*/
7+
8+
verify.completions({
9+
marker: ["1"],
10+
includes: ["bar"]
11+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
//// const foo = 1;
4+
//// const bar = 2;
5+
//// const obj: any = {
6+
//// foo b/*1*/
7+
8+
verify.completions({
9+
marker: ["1"],
10+
includes: ["bar"]
11+
});

tests/cases/fourslash/globalCompletionListInsideObjectLiterals.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
// 5, 6: Literal member completion after member name with empty member expression.
2929
const exact = ["p1", "p2", "p3", "p4", ...completion.globalsPlus(["ObjectLiterals"])];
3030
verify.completions(
31-
{ marker: ["1"], exact, isNewIdentifierLocation: true },
32-
{ marker: ["2", "3", "5", "6"], exact },
33-
{ marker: "4", exact: undefined },
31+
{ marker: ["1",], exact, isNewIdentifierLocation: true },
32+
{ marker: ["2", "3", "4", "5", "6"], exact }
3433
);

0 commit comments

Comments
 (0)