Skip to content

Commit 857ab1a

Browse files
jakebaileyandrewbranch
authored andcommitted
Make signature help arg index handling more like Strada (microsoft#1586)
1 parent ebe7530 commit 857ab1a

File tree

3 files changed

+122
-86
lines changed

3 files changed

+122
-86
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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/fourslash/tests/util"
8+
"github.com/microsoft/typescript-go/internal/lsp/lsproto"
9+
"github.com/microsoft/typescript-go/internal/testutil"
10+
)
11+
12+
func TestSignatureHelpTokenCrash2(t *testing.T) {
13+
t.Parallel()
14+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
15+
const content = `
16+
function foo<T, U>(x: string, y: T, z: U) {
17+
18+
}
19+
20+
foo<number,number>/*1*/("hello", 123,456)
21+
`
22+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
23+
f.VerifySignatureHelp(t, &fourslash.SignatureHelpCase{
24+
MarkerInput: "1",
25+
Expected: nil,
26+
Context: &lsproto.SignatureHelpContext{
27+
IsRetrigger: false,
28+
TriggerCharacter: PtrTo("("),
29+
TriggerKind: lsproto.SignatureHelpTriggerKindTriggerCharacter,
30+
},
31+
})
32+
}

internal/ls/completions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4692,12 +4692,12 @@ type argumentInfoForCompletions struct {
46924692

46934693
func getArgumentInfoForCompletions(node *ast.Node, position int, file *ast.SourceFile, typeChecker *checker.Checker) *argumentInfoForCompletions {
46944694
info := getImmediatelyContainingArgumentInfo(node, position, file, typeChecker)
4695-
if info == nil || info.isTypeParameterList || info.invocation.callInvocation == nil || info.argumentIndex == nil {
4695+
if info == nil || info.isTypeParameterList || info.invocation.callInvocation == nil {
46964696
return nil
46974697
}
46984698
return &argumentInfoForCompletions{
46994699
invocation: info.invocation.callInvocation.node,
4700-
argumentIndex: *info.argumentIndex,
4700+
argumentIndex: info.argumentIndex,
47014701
argumentCount: info.argumentCount,
47024702
}
47034703
}

0 commit comments

Comments
 (0)