From 16f7bd0a2e41b3556b6accefcde9d98e0b71c8e0 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 23 Oct 2025 10:46:50 +0200 Subject: [PATCH] editor: Translate utf16 to utf8 offsets in `copy_highlight_json` (#40981) Fixes ZED-2FM Release Notes: - Fixed panic in copy highlight json action --- crates/editor/src/editor.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b9075e47e4681809228ee827db5805a7b402f921..c13458e3816448057030391b0673a8f731803aa8 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -21351,7 +21351,10 @@ impl Editor { if selection.range.is_empty() { None } else { - Some(selection.range) + Some( + snapshot.offset_utf16_to_offset(OffsetUtf16(selection.range.start)) + ..snapshot.offset_utf16_to_offset(OffsetUtf16(selection.range.end)), + ) } }) .unwrap_or_else(|| 0..snapshot.len());