Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions internal/fourslash/tests/signatureHelpCrash_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestSignatureHelpTokenCrash2(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `
function foo<T, U>(x: string, y: T, z: U) {

}

foo<number,number>/*1*/("hello", 123,456)
`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifySignatureHelp(t, &fourslash.SignatureHelpCase{
MarkerInput: "1",
Expected: nil,
Context: &lsproto.SignatureHelpContext{
IsRetrigger: false,
TriggerCharacter: PtrTo("("),
TriggerKind: lsproto.SignatureHelpTriggerKindTriggerCharacter,
},
})
}
4 changes: 2 additions & 2 deletions internal/ls/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4692,12 +4692,12 @@ type argumentInfoForCompletions struct {

func getArgumentInfoForCompletions(node *ast.Node, position int, file *ast.SourceFile, typeChecker *checker.Checker) *argumentInfoForCompletions {
info := getImmediatelyContainingArgumentInfo(node, position, file, typeChecker)
if info == nil || info.isTypeParameterList || info.invocation.callInvocation == nil || info.argumentIndex == nil {
if info == nil || info.isTypeParameterList || info.invocation.callInvocation == nil {
return nil
}
return &argumentInfoForCompletions{
invocation: info.invocation.callInvocation.node,
argumentIndex: *info.argumentIndex,
argumentIndex: info.argumentIndex,
argumentCount: info.argumentCount,
}
}
Expand Down
Loading
Loading