Skip to content

Prevent LSP position-conversion panic after content mapper failure - #65554

Draft
Daniel Rosenwasser (DanielRosenwasser) wants to merge 4 commits into
mainfrom
copilot/fix-lsp-panics-slice-bounds
Draft

Daniel Rosenwasser (DanielRosenwasser) wants to merge 4 commits into
mainfrom
copilot/fix-lsp-panics-slice-bounds

Conversation

@DanielRosenwasser

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

When a content mapper fails, its empty virtual file retains the original document’s line map. In a non-ASCII document, hover and inlay-hint requests can then scan beyond the virtual text and panic.

  • Change: Clamp line boundaries to the available virtual text before converting LSP positions.
  • Regression coverage: Exercise hover-position and inlay-hint range conversion against a failed-mapper placeholder.

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) changed the title [WIP] Fix LSP panic with slice bounds out of range Prevent LSP position-conversion panic after content mapper failure Nov 17, 2026
assert.Equal(t, positions[1].Position, core.TextPos(2))
}

func TestConvertersFailedContentMapperPosition(t *testing.T) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This need a better explanation. What is failing? Why is it failing? What does this test prove?

@DanielRosenwasser

Copy link
Copy Markdown
Member Author

Copilot fix

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Copilot fix

Added an explanation above the regression test: failed mapping leaves empty virtual text with the original non-ASCII line map, so the second line's byte-3 start previously caused an out-of-bounds scan. The test verifies hover and inlay-hint conversions clamp to offset 0. Addressed in 2bb773470; targeted test and npx hereby validate pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP panics with "slice bounds out of range" after a content mapper fails

2 participants