forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add completion for promise context (microsoft#32101)
* add completion for promise context * check insert text inside add symbol helper * fix incorrect branch * avoid completions with includeCompletionsWithInsertText perferences * avoid useless parameter
- Loading branch information
1 parent
e9073a8
commit 9942c60
Showing
7 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
//// async function foo(x: Promise<string>) { | ||
//// [|x./**/|] | ||
//// } | ||
|
||
const replacementSpan = test.ranges()[0] | ||
verify.completions({ | ||
marker: "", | ||
includes: [ | ||
"then", | ||
{ name: "trim", insertText: '(await x).trim', replacementSpan }, | ||
], | ||
preferences: { | ||
includeInsertTextCompletions: true, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
//// interface Foo { foo: string } | ||
//// async function foo(x: Promise<Foo>) { | ||
//// [|x./**/|] | ||
//// } | ||
|
||
const replacementSpan = test.ranges()[0] | ||
verify.completions({ | ||
marker: "", | ||
includes: [ | ||
"then", | ||
{ name: "foo", insertText: '(await x).foo', replacementSpan }, | ||
], | ||
preferences: { | ||
includeInsertTextCompletions: true, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
//// interface Foo { ["foo-foo"]: string } | ||
//// async function foo(x: Promise<Foo>) { | ||
//// [|x./**/|] | ||
//// } | ||
|
||
const replacementSpan = test.ranges()[0] | ||
verify.completions({ | ||
marker: "", | ||
includes: [ | ||
"then", | ||
{ name: "foo-foo", insertText: '(await x)["foo-foo"]', replacementSpan, }, | ||
], | ||
preferences: { | ||
includeInsertTextCompletions: true, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
//// function foo(x: Promise<string>) { | ||
//// [|x./**/|] | ||
//// } | ||
|
||
const replacementSpan = test.ranges()[0] | ||
verify.completions({ | ||
marker: "", | ||
includes: ["then"], | ||
excludes: ["trim"], | ||
preferences: { | ||
includeInsertTextCompletions: true, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
//// interface Foo { foo: string } | ||
//// async function foo(x: (a: number) => Promise<Foo>) { | ||
//// [|x(1)./**/|] | ||
//// } | ||
|
||
const replacementSpan = test.ranges()[0] | ||
verify.completions({ | ||
marker: "", | ||
includes: [ | ||
"then", | ||
{ name: "foo", insertText: '(await x(1)).foo', replacementSpan }, | ||
], | ||
preferences: { | ||
includeInsertTextCompletions: true, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
//// async function foo(x: Promise<string>) { | ||
//// [|x./**/|] | ||
//// } | ||
|
||
const replacementSpan = test.ranges()[0] | ||
verify.completions({ | ||
marker: "", | ||
exact: [ | ||
"then", | ||
"catch" | ||
], | ||
preferences: { | ||
includeInsertTextCompletions: false, | ||
}, | ||
}); |