-
Notifications
You must be signed in to change notification settings - Fork 658
Fix panic when hovering over functions with JSDoc links #1339
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 our terms of service and privacy 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
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Revert everything you just did. Do not make compiler tests, do not make AST unit tests. The bug is in hover, so a compiler test will not reproduce it at all. Start by making a test next to |
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Done. I've reverted all the previous changes and created a proper hover test in |
… JSDoc links Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
The TypeScript Native Preview extension was crashing with a panic when hovering over functions that contain JSDoc links (
{@link}
,{@linkcode}
,{@linkplain}
) in their documentation. This was happening because theNode.Text()
method ininternal/ast/ast.go
didn't handle JSDoc link node types.Error before fix:
Root cause:
The
writeComments
function ininternal/ls/hover.go
callscomment.Text()
on JSDoc nodes, which internally calls theNode.Text()
method. However, the switch statement inNode.Text()
was missing cases for:KindJSDocLink
KindJSDocLinkCode
KindJSDocLinkPlain
Solution:
Added the missing cases to handle JSDoc link types in the
Node.Text()
method. Since these types inherit fromJSDocCommentBase
(which has atext []string
field), they follow the same pattern asKindJSDocText
:Testing:
Text()
method works for JSDoc link nodesThe fix is minimal and surgical - it only adds the missing cases without modifying any existing functionality.
Fixes #1323.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.