Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Lukas Wirth16f7bd0a2e41
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index b9075e47e46..c13458e3816 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());