Edit tool panics on UTF-8 multi-byte character boundary when editing Chinese text

Resolved 💬 7 comments Opened Jan 1, 2026 by lostshin Closed Feb 26, 2026

Description

When using the Edit tool to modify a Markdown file containing Chinese characters, Claude Code crashes with a Rust panic. The error indicates an attempt to slice a string at a byte index that falls inside a multi-byte UTF-8 character.

Steps to Reproduce

  1. Create a Markdown file with Chinese text containing full-width quotation marks (「」)
  2. Use the Edit tool to replace a string that appears near these characters
  3. The CLI crashes during the edit operation

Error Message

thread '<unnamed>' (4814716) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 113 is not a char boundary; it is inside '「' (bytes 111..114) of `》四章 7 節也問:「你哪一樣東西不是領受來的呢?」這兩段經文放在一起,突然讓「特權」這個詞`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
[1]    48646 abort      claude -c

Environment

  • OS: macOS (Darwin 25.3.0)
  • Claude Code version: 2.0.76

Analysis

The error suggests that somewhere in the Edit tool's implementation, a byte index is being used to slice a UTF-8 string without verifying it falls on a character boundary. Chinese characters (and full-width punctuation like 「」) occupy 3 bytes in UTF-8. When the slice index lands in the middle of such a character (e.g., byte 113 inside bytes 111-114), Rust panics as expected.

Suggested Fix

Ensure all string slicing operations use character-aware indexing or validate byte boundaries before slicing.

View original on GitHub ↗

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