Merge pull request #27203 from sbaidon/signatureHelpInAdjacentBlockBody
Fix signature help not showing in block body bug
This commit is contained in:
commit
8474949336
2 changed files with 19 additions and 3 deletions
|
@ -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)}`);
|
||||
|
|
15
tests/cases/fourslash/signatureHelpInAdjacentBlockBody.ts
Normal file
15
tests/cases/fourslash/signatureHelpInAdjacentBlockBody.ts
Normal 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",
|
||||
});
|
Loading…
Reference in a new issue