- Notifications
You must be signed in to change notification settings - Fork664
Fix crash in completions following call expressions#1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
…ck for argumentIndexCo-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Convert this file into a fourslash completions test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Converted the test to proper fourslash format using numbered markers (/*1*/
,/*2*/
) instead of/**/
and consolidated into a single test function with multiple marker verification. (385a152)
… with numbered markersCo-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
I was wrong. Revert the last change, and then
|
…ut of gen folderCo-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Reverted the numbered markers change, removed the unnecessary second test case, and moved the test out of the gen folder as requested. (a84cdca) |
There was a problem hiding this 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 fixes a runtime panic that occurred when requesting code completions immediately after call expressions in TypeScript code. The crash was caused by attempting to dereference a nil pointer in the completion handling logic.
- Added a nil check for
info.argumentIndex
in thegetArgumentInfoForCompletions
function - Created comprehensive test coverage to verify the fix and prevent regression
- Ensured users now receive appropriate infix operator completions (like
satisfies
,as
) instead of crashing
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
internal/ls/completions.go | Added nil check forinfo.argumentIndex to prevent panic when dereferencing |
internal/fourslash/tests/completionAfterCallExpression_test.go | Added test case to verify completion behavior after call expressions and prevent regression |
Comments suppressed due to low confidence (2)
internal/fourslash/tests/completionAfterCallExpression_test.go:16
- Consider adding additional test cases for different call expression scenarios, such as chained calls (e.g.,
obj.method()./**/
) or calls with arguments (e.g.,func(arg)./**/
) to ensure comprehensive coverage.
const content1 = `let x = someCall() /**/`
Uh oh!
There was an error while loading.Please reload this page.
This PR fixes a crash that occurred when requesting completions immediately after a call expression, such as:
Problem
The crash was happening in the
getArgumentInfoForCompletions
function when it attempted to dereferenceinfo.argumentIndex
without checking if it was nil. The stack trace showed:Root Cause
When the cursor is positioned after a call expression but not inside its argument list, the
getArgumentIndex
function can returnnil
. However,getArgumentInfoForCompletions
was only checking ifinfo
itself was nil, not ifinfo.argumentIndex
was nil, before dereferencing it with*info.argumentIndex
.Solution
Added a nil check for
info.argumentIndex
in the condition before creating theargumentInfoForCompletions
struct:Testing
satisfies
,as
, etc.)Fixes#1416.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.