Skip to content

Commit f616d7f

Browse files
Fix crash in completions following call expressions (#1417)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: DanielRosenwasser <[email protected]>
1 parent d9f6961 commit f616d7f

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
"github.com/microsoft/typescript-go/internal/testutil"
8+
)
9+
10+
func TestCompletionAfterCallExpression(t *testing.T) {
11+
t.Parallel()
12+
13+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
14+
15+
const content = `let x = someCall() /**/`
16+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
17+
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
18+
IsIncomplete: false,
19+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
20+
CommitCharacters: &defaultCommitCharacters,
21+
EditRange: ignored,
22+
},
23+
Items: &fourslash.CompletionsExpectedItems{
24+
Includes: []fourslash.CompletionsExpectedItem{
25+
"satisfies",
26+
"as",
27+
},
28+
},
29+
})
30+
}

internal/ls/completions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4556,7 +4556,7 @@ type argumentInfoForCompletions struct {
45564556

45574557
func getArgumentInfoForCompletions(node *ast.Node, position int, file *ast.SourceFile, typeChecker *checker.Checker) *argumentInfoForCompletions {
45584558
info := getImmediatelyContainingArgumentInfo(node, position, file, typeChecker)
4559-
if info == nil || info.isTypeParameterList || info.invocation.callInvocation == nil {
4559+
if info == nil || info.isTypeParameterList || info.invocation.callInvocation == nil || info.argumentIndex == nil {
45604560
return nil
45614561
}
45624562
return &argumentInfoForCompletions{

0 commit comments

Comments
 (0)