Skip to content

Commit

Permalink
Fix start-position of next search (#1904)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeepee authored Apr 1, 2022
1 parent 47fe739 commit 8165feb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,11 +1488,11 @@ fn search_impl(
// Get the right side of the primary block cursor for forward search, or the
// grapheme before the start of the selection for reverse search.
let start = match direction {
Direction::Forward => text.char_to_byte(graphemes::next_grapheme_boundary(
Direction::Forward => text.char_to_byte(graphemes::ensure_grapheme_boundary_next(
text,
selection.primary().to(),
)),
Direction::Backward => text.char_to_byte(graphemes::prev_grapheme_boundary(
Direction::Backward => text.char_to_byte(graphemes::ensure_grapheme_boundary_prev(
text,
selection.primary().from(),
)),
Expand Down

0 comments on commit 8165feb

Please sign in to comment.