Skip to content

Fix "Not a subspan" crash in signature help on error-recovered JSX - #4778

Open
johnfav03 wants to merge 1 commit into
microsoft:mainfrom
johnfav03:repro/i-frigate-sighelp-jsx
Open

Fix "Not a subspan" crash in signature help on error-recovered JSX#4778
johnfav03 wants to merge 1 commit into
microsoft:mainfrom
johnfav03:repro/i-frigate-sighelp-jsx

Conversation

@johnfav03

Copy link
Copy Markdown
Contributor

Fixes an issue uncovered in #4532 (comment); An incomplete JSX attribute immediately followed on the next line by a closing tag is error-recovered (ex: <a><b c=\n</a>). Requesting signature help there calls findRightmostValidToken, which scans and consumes the closing tag's </, creating a span that overruns its parent attribute.

Copilot AI review requested due to automatic review settings July 28, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents signature-help crashes when malformed JSX recovery produces tokens outside their parent span.

Changes:

  • Bounds rightmost-token scanning by the containing range.
  • Adds a fourslash regression test for incomplete JSX attributes.

Reviewed changes

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

File Description
internal/astnav/tokens.go Restricts synthesized token scanning to valid boundaries.
internal/fourslash/tests/signatureHelpIncompleteJsxAttribute_test.go Adds malformed-JSX signature-help coverage.

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @Filename: /a.tsx
<a><b c=
/*a*/</a>`
Comment thread internal/astnav/tokens.go
token := scanNavigationToken(scanner, n)
tokenStart := scanner.TokenStart()
if tokenStart >= position {
if tokenStart >= min(endPos, position) {
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.

2 participants