Rust panic when displaying diffs containing Japanese text

Resolved 💬 3 comments Opened Jan 6, 2026 by GigiTiti-Kai Closed Jan 6, 2026

Environment

  • Claude Code Version: 2.0.76
  • OS: Windows 11
  • Context: Editing JSON/JavaScript files containing Japanese text

Description

Claude Code crashes with a Rust panic when attempting to display diffs or previews of edits involving Japanese (multi-byte UTF-8) text. The edits themselves are applied successfully, but the application crashes during the result display phase.

Error Messages

Crash 1:

thread '<unnamed>' panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb\library\core\src\str\mod.rs:833:21:
byte index 53 is not a char boundary; it is inside 'も' (bytes 51..54) of `が前日夜に「おやすみ」と言っていても、翌日の返信では「ゆっくり休めた?」「起きてるかな?」「よく眠れた?」を使う。「お`

Crash 2:

thread '<unnamed>' panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb\library\core\src\str\mod.rs:833:21:
byte index 8 is not a char boundary; it is inside 'い' (bytes 6..9) of `ださい。');`

Root Cause Analysis

The error indicates that string slicing is being performed at byte indices that fall within multi-byte UTF-8 characters. Japanese characters occupy 3 bytes each in UTF-8, and the code appears to be slicing at arbitrary byte positions without checking for character boundaries.

Steps to Reproduce

  1. Edit a file containing Japanese text (e.g., JSON with Japanese strings)
  2. Make changes that result in a diff being displayed
  3. Crash occurs intermittently during diff/preview rendering

Frequency

  • Does not occur every time
  • Intermittent, but can happen in bursts during certain editing sessions

Impact

  • Low-Medium: Edits are applied successfully despite the crash
  • User experience is disrupted by needing to restart the session

Suggested Fix

Use character-boundary-aware string slicing methods like str.char_indices() or str.get(start..end) instead of direct byte indexing when truncating or displaying text previews.

View original on GitHub ↗

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