Merge pull request #27203 from sbaidon/signatureHelpInAdjacentBlockBody

Fix signature help not showing in block body bug
This commit is contained in:
Daniel Rosenwasser 2018-10-07 23:07:59 -07:00 committed by GitHub
commit 8474949336
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View file

@ -38,7 +38,8 @@ namespace ts.SignatureHelp {
return undefined;
}
const argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile, typeChecker);
const isManuallyInvoked = !!triggerReason && triggerReason.kind === "invoked";
const argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile, typeChecker, isManuallyInvoked);
if (!argumentInfo) return undefined;
cancellationToken.throwIfCancellationRequested();
@ -450,8 +451,8 @@ namespace ts.SignatureHelp {
return createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
}
function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile, checker: TypeChecker): ArgumentListInfo | undefined {
for (let n = node; !isBlock(n) && !isSourceFile(n); n = n.parent) {
function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile, checker: TypeChecker, isManuallyInvoked: boolean): ArgumentListInfo | undefined {
for (let n = node; isManuallyInvoked || (!isBlock(n) && !isSourceFile(n)); n = n.parent) {
// If the node is not a subspan of its parent, this is a big problem.
// There have been crashes that might be caused by this violation.
Debug.assert(rangeContainsRange(n.parent, n), "Not a subspan", () => `Child: ${Debug.showSyntaxKind(n)}, parent: ${Debug.showSyntaxKind(n.parent)}`);

View file

@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
////declare function foo(...args);
////
////foo(() => {/*1*/}/*2*/)
goTo.marker("1");
verify.signatureHelpPresentForTriggerReason({
kind: "invoked",
});
goTo.marker("2");
verify.signatureHelpPresentForTriggerReason({
kind: "invoked",
});