From f4b488e380e28aa36a06ad400d6656fa864ba5b7 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 6 Jun 2025 18:21:29 -0400 Subject: [PATCH] Remove unused `helix_core::graphemes::is_grapheme_boundary` This function was never used and will be superseded by `RopeSliceExt::is_grapheme_boundary` (which accepts a byte index rather than a character index) once we transition to Ropey v2. In the meantime any callers should convert to byte index and use the `RopeSliceExt` extension rather than form new dependencies on this. --- helix-core/src/graphemes.rs | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/helix-core/src/graphemes.rs b/helix-core/src/graphemes.rs index 33d237cb9..4cbb57464 100644 --- a/helix-core/src/graphemes.rs +++ b/helix-core/src/graphemes.rs @@ -242,34 +242,6 @@ pub fn ensure_grapheme_boundary_prev(slice: RopeSlice, char_idx: usize) -> usize } } -/// Returns whether the given char position is a grapheme boundary. -#[must_use] -pub fn is_grapheme_boundary(slice: RopeSlice, char_idx: usize) -> bool { - // Bounds check - debug_assert!(char_idx <= slice.len_chars()); - - // We work with bytes for this, so convert. - let byte_idx = slice.char_to_byte(char_idx); - - // Get the chunk with our byte index in it. - let (chunk, chunk_byte_idx, _, _) = slice.chunk_at_byte(byte_idx); - - // Set up the grapheme cursor. - let mut gc = GraphemeCursor::new(byte_idx, slice.len_bytes(), true); - - // Determine if the given position is a grapheme cluster boundary. - loop { - match gc.is_boundary(chunk, chunk_byte_idx) { - Ok(n) => return n, - Err(GraphemeIncomplete::PreContext(n)) => { - let (ctx_chunk, ctx_byte_start, _, _) = slice.chunk_at_byte(n - 1); - gc.provide_context(ctx_chunk, ctx_byte_start); - } - Err(_) => unreachable!(), - } - } -} - /// A highly compressed Cow<'a, str> that holds /// atmost u31::MAX bytes and is readonly pub struct GraphemeStr<'a> {