[BUG] Rust panic when editing file containing Chinese characters in diff preview

Resolved 💬 3 comments Opened Dec 18, 2025 by iseeweb Closed Dec 21, 2025

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 I edit a Markdown file containing Chinese characters mixed with ASCII text (like 持4-bit量化), Claude Code crashes with a Rust panic error.

Environment:

  • OS: macOS (Darwin 25.1.0)
  • Claude Code Version: 2.0.72
  • Shell: zsh

Error message:
thread '<unnamed>' (72049) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 13 is not a char boundary; it is inside '化' (bytes 11..14) of 持4-bit量化
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
[1] 5636 abort Claude

What Should Happen?

Claude Code should correctly handle UTF-8 strings containing multi-byte characters (like Chinese) when displaying diffs.

String slicing should respect character boundaries, not byte boundaries. The application should use character-aware slicing methods like chars().take(n) or the unicode-segmentation crate instead of byte-based slicing.

The diff preview should display correctly without crashing, even when the content contains mixed Chinese and ASCII text.

Error Messages/Logs

Steps to Reproduce

Steps to reproduce:

  1. Use Claude Code to edit a Markdown file
  2. The file contains Chinese text mixed with ASCII, like 持4-bit量化 (meaning "with 4-bit quantization")
  3. When Claude Code attempts to show the diff preview of the edit, it crashes

The crash occurs because the code tries to slice a UTF-8 string at byte index 13, which is inside the Chinese character '化' (bytes 11-14). This is an invalid byte boundary for UTF-8 multi-byte characters.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.72

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Cursor

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗