Skip to content

Commit 8474949

Browse files
Merge pull request microsoft#27203 from sbaidon/signatureHelpInAdjacentBlockBody
Fix signature help not showing in block body bug
2 parents 85a3475 + bb58558 commit 8474949

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/services/signatureHelp.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ namespace ts.SignatureHelp {
3838
return undefined;
3939
}
4040

41-
const argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile, typeChecker);
41+
const isManuallyInvoked = !!triggerReason && triggerReason.kind === "invoked";
42+
const argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile, typeChecker, isManuallyInvoked);
4243
if (!argumentInfo) return undefined;
4344

4445
cancellationToken.throwIfCancellationRequested();
@@ -450,8 +451,8 @@ namespace ts.SignatureHelp {
450451
return createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
451452
}
452453

453-
function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile, checker: TypeChecker): ArgumentListInfo | undefined {
454-
for (let n = node; !isBlock(n) && !isSourceFile(n); n = n.parent) {
454+
function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile, checker: TypeChecker, isManuallyInvoked: boolean): ArgumentListInfo | undefined {
455+
for (let n = node; isManuallyInvoked || (!isBlock(n) && !isSourceFile(n)); n = n.parent) {
455456
// If the node is not a subspan of its parent, this is a big problem.
456457
// There have been crashes that might be caused by this violation.
457458
Debug.assert(rangeContainsRange(n.parent, n), "Not a subspan", () => `Child: ${Debug.showSyntaxKind(n)}, parent: ${Debug.showSyntaxKind(n.parent)}`);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////declare function foo(...args);
4+
////
5+
////foo(() => {/*1*/}/*2*/)
6+
7+
goTo.marker("1");
8+
verify.signatureHelpPresentForTriggerReason({
9+
kind: "invoked",
10+
});
11+
12+
goTo.marker("2");
13+
verify.signatureHelpPresentForTriggerReason({
14+
kind: "invoked",
15+
});

0 commit comments

Comments
 (0)