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
2025-10-23 08:46:50 +00:00
committed by GitHub
parent c529a066bf
commit 16f7bd0a2e
+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());