aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/graphemes.rs5
-rw-r--r--helix-core/src/syntax.rs8
2 files changed, 3 insertions, 10 deletions
diff --git a/helix-core/src/graphemes.rs b/helix-core/src/graphemes.rs
index aa898684..c0c61775 100644
--- a/helix-core/src/graphemes.rs
+++ b/helix-core/src/graphemes.rs
@@ -333,10 +333,7 @@ impl<'a> Iterator for RopeGraphemes<'a> {
}
if a < self.cur_chunk_start {
- let a_char = self.text.byte_to_char(a);
- let b_char = self.text.byte_to_char(b);
-
- Some(self.text.slice(a_char..b_char))
+ Some(self.text.byte_slice(a..b))
} else {
let a2 = a - self.cur_chunk_start;
let b2 = b - self.cur_chunk_start;
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 3fc91efc..f76683b9 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -576,9 +576,7 @@ pub struct Syntax {
}
fn byte_range_to_str(range: std::ops::Range<usize>, source: RopeSlice) -> Cow<str> {
- let start_char = source.byte_to_char(range.start);
- let end_char = source.byte_to_char(range.end);
- Cow::from(source.slice(start_char..end_char))
+ Cow::from(source.byte_slice(range))
}
impl Syntax {
@@ -1197,9 +1195,7 @@ impl<'a> TextProvider<'a> for RopeProvider<'a> {
type I = ChunksBytes<'a>;
fn text(&mut self, node: Node) -> Self::I {
- let start_char = self.0.byte_to_char(node.start_byte());
- let end_char = self.0.byte_to_char(node.end_byte());
- let fragment = self.0.slice(start_char..end_char);
+ let fragment = self.0.byte_slice(node.start_byte()..node.end_byte());
ChunksBytes {
chunks: fragment.chunks(),
}