diff --git a/crates/edit_prediction_cli/src/format_prompt.rs b/crates/edit_prediction_cli/src/format_prompt.rs index 113baf04d08e69912ef8d0f0005d24a82fa47998..702af3091a2d5f292806034ad875af861c484e2f 100644 --- a/crates/edit_prediction_cli/src/format_prompt.rs +++ b/crates/edit_prediction_cli/src/format_prompt.rs @@ -160,7 +160,7 @@ pub fn zeta2_output_for_patch( // We need to add where the hunk context matched in the editable region to compute // the actual cursor position in the result. let hunk_start = first_hunk_offset.unwrap_or(0); - let offset = (hunk_start + cursor_offset).min(result.len()); + let offset = result.floor_char_boundary((hunk_start + cursor_offset).min(result.len())); result.insert_str(offset, zeta_prompt::CURSOR_MARKER); }