Skip to content

Commit 31ce9d1

Browse files
Copilotjakebailey
andcommitted
Add test cases for nested calls and applicable range
Added two new test cases: 1. TestSignatureHelpNestedCalls: Validates that outer calls take precedence when the cursor is outside inner call's arguments, as per issue #1419 2. TestSignatureHelpApplicableRange: Validates that signature help is not shown for positions outside the call Both tests pass, confirming the fix works correctly. Co-authored-by: jakebailey <[email protected]>
1 parent fac1f55 commit 31ce9d1

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 TestSignatureHelpApplicableRange(t *testing.T) {
11+
t.Parallel()
12+
13+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
14+
const content = `let obj = {
15+
foo(s: string): string {
16+
return s;
17+
}
18+
};
19+
20+
let s =/*a*/ obj.foo("Hello, world!")/*b*/
21+
/*c*/;`
22+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
23+
24+
// Markers a, b, c should NOT show signature help (outside the call)
25+
f.VerifyNoSignatureHelpForMarkers(t, "a", "b", "c")
26+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 TestSignatureHelpNestedCalls(t *testing.T) {
11+
t.Parallel()
12+
13+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
14+
const content = `function foo(s: string) { return s; }
15+
function bar(s: string) { return s; }
16+
let s = foo(/*a*/ /*b*/bar/*c*/(/*d*/"hello"/*e*/)/*f*/);`
17+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
18+
19+
// Markers a, b, c should show foo (outer call)
20+
f.GoToMarker(t, "a")
21+
f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(s: string): string"})
22+
23+
f.GoToMarker(t, "b")
24+
f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(s: string): string"})
25+
26+
f.GoToMarker(t, "c")
27+
f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(s: string): string"})
28+
29+
// Marker d should show bar (inside inner call)
30+
f.GoToMarker(t, "d")
31+
f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "bar(s: string): string"})
32+
33+
// Markers e, f should show foo (after inner call)
34+
f.GoToMarker(t, "e")
35+
f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(s: string): string"})
36+
37+
f.GoToMarker(t, "f")
38+
f.VerifySignatureHelp(t, fourslash.VerifySignatureHelpOptions{Text: "foo(s: string): string"})
39+
}

0 commit comments

Comments
 (0)