chat: avoid splitting surrogate pairs in read_file - #331005
Merged
roblourens merged 1 commit intoAug 16, 2026
Merged
roblourens merged 1 commit into
roblourens merged 1 commit into
Conversation
Copilot started reviewing on behalf of
Martin Check (martincheck)
August 15, 2026 05:10
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents read_file truncation from producing malformed Unicode when the limit intersects a UTF-16 surrogate pair.
Changes:
- Adjusts the truncation boundary to preserve surrogate pairs.
- Adds regression coverage for an astral character at the boundary.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
extensions/copilot/src/extension/tools/node/readFileTool.tsx |
Safely adjusts the line truncation boundary. |
extensions/copilot/src/extension/tools/node/test/readFile.spec.tsx |
Tests surrogate-pair boundary handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
roblourens
enabled auto-merge (squash)
August 15, 2026 20:31
Dmitriy Vasyura (dmitrivMS)
approved these changes
Aug 15, 2026
Vijay Upadya (vijayupadya)
approved these changes
Aug 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #330999
This change keeps
read_fileline truncation from splitting a UTF-16 surrogate pair at the 2,000-code-unit boundary. When the boundary falls between a high and low surrogate, truncation moves back one code unit before appending the existing marker.A regression test covers an astral character beginning at index 1,999.
Validation on
80b2a71e868059b3177b68b125310f2f690252b9with Node.js 22.23.2 and@vscode/copilot-api0.5.2:readFile.spec.tsx: 35 passednpm run typecheck: passednpm run compile: passedgit diff --check: passed