Skip to content

Conversation

jakebailey
Copy link
Member

Fixes #1497

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the signature help implementation to remove nullable argument index handling, making it more like "Strada" (likely referring to another TypeScript implementation or reference). The changes simplify the code by treating argument index as a non-nullable integer value instead of an optional pointer.

  • Removes complex null-checking logic for argument indices
  • Changes argumentIndex from *int to int throughout the codebase
  • Simplifies the argument index calculation and handling logic

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/ls/signaturehelp.go Main refactoring removing nullable argument index logic and simplifying related functions
internal/ls/completions.go Updates completion logic to work with non-nullable argument index
internal/fourslash/tests/signatureHelpCrash_test.go Adds regression test for signature help crash scenario

return 0
}
return *argumentCount
return getArgumentIndexOrCount(getTokenFromNodeList(arguments, node.Parent, sourceFile), nil, c)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After #1584 I'm pretty sure we could drop getTokenFromNodeList, but potentially not because you can't pass a NodeList into getChildrenFromNonJSDocNode... (Or I'm missing the obvious transform that makes getChildrenFromNonJSDocNode work)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this turns out to be complicated, for another day

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think you'd have to make getChildrenFromNonJSDocNode take in an optional slice of nodes (instead of it obtaining one by node.ForEachChild() and also a range... Or you could just extract the part of getChildrenFromNonJSDocNode that collects nodes + tokens into a separate one and reuse that for node lists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea, better than what I was trying.

@jakebailey jakebailey added this pull request to the merge queue Aug 14, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 14, 2025
@jakebailey jakebailey added this pull request to the merge queue Aug 14, 2025
Merged via the queue into main with commit ae2bacc Aug 14, 2025
22 checks passed
@jakebailey jakebailey deleted the jabaile/fix-1497 branch August 14, 2025 23:53
andrewbranch pushed a commit to andrewbranch/typescript-go that referenced this pull request Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signature help crash between type arguments and value arguments
2 participants