on master help sign in
Fix start-position of next search (#1904)

The search implementation would start searching at the next grapheme boundary after the previous selection. In case the next occurence of the needle is immediately after the current selection, this occurence would not be found (without wraparound) because the first grapheme is skipped. The correct approach is to use the ensure_grapheme_boundary functions instead of using the functions that skip unconditionally to the next grapheme.

commit8165febe23cbd8bb9cd99cceac9d09b81f35456e authorjeepee <jeepee@users.noreply.github.com> dateFri 1 Apr 2022, 15:16 (5 years ago) parent47fe739
1 file changed+2−2
helix-term/src/commands.rs+2−2
helix-term/src/commands.rs+2−2
@@ -1488,11 +1488,11 @@ fn search_impl(
14881488 // Get the right side of the primary block cursor for forward search, or the
14891489 // grapheme before the start of the selection for reverse search.
14901490 let start = match direction {
1491− Direction::Forward => text.char_to_byte(graphemes::next_grapheme_boundary(
1491+ Direction::Forward => text.char_to_byte(graphemes::ensure_grapheme_boundary_next(
14921492 text,
14931493 selection.primary().to(),
14941494 )),
1495− Direction::Backward => text.char_to_byte(graphemes::prev_grapheme_boundary(
1495+ Direction::Backward => text.char_to_byte(graphemes::ensure_grapheme_boundary_prev(
14961496 text,
14971497 selection.primary().from(),
14981498 )),