editor: Translate utf16 to utf8 offsets in copy_highlight_json (#40981)

Fixes ZED-2FM

Release Notes:

- Fixed panic in copy highlight json action
This commit is contained in:
Lukas Wirth authored and GitHub committed 2025-10-23 08:46:50 +00:00
1 parent db46898fb3
commit 469a05156a
1 file changed
+4 -1
+4 -1
View File
@@ -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());