[BUG] Diff view shows extra line break when line contains CJK characters
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When viewing code diffs that contain Chinese/CJK characters, the diff view incorrectly renders an extra line break after lines with CJK text. This appears to be a character width calculation issue.
Lines containing CJK characters (e.g., Chinese comments) show an unwanted empty line with background coloring immediately after, as shown in the screenshot below.
(The screenshot shows line 324 with a Chinese comment // 构建数据组(只包含接口B的字段) followed by an extra blank line with background coloring)
<img width="797" height="165" alt="Image" src="https://github.com/user-attachments/assets/0c796629-7708-49f7-8d9e-08664876f3f3" />
What Should Happen?
The diff background highlighting should correctly span the entire line without producing extra line breaks.
CJK characters are full-width characters that occupy 2 terminal columns, but the rendering logic appears to calculate them as single-width (1 column). This causes the background color block length to be miscalculated, resulting in overflow that wraps to a new line.
Error Messages/Logs
Steps to Reproduce
foreach ($this->itemsB as $idx => $item) {
$existing = $existingRecords->get($idx);
// 构建数据数组 (只包含接口B的字段)
$data = [
'idx' => $item['idx'],
'shop_id' => $item['shop_id'],
'external_shop_name' => $item['external_shop_name'],
'shop_platform' => $item['shop_platform'],
'douyin_id_b' => $item['douyin_id_b'],
'douyin_name_b' => $item['douyin_name_b'],
'douyin_avatar_b' => $item['douyin_avatar_b'],
'douyin_type_b' => $item['douyin_type_b'],
];
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.14
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗