Skip to content

Commit

Permalink
Adjust logic for ensuring surround range encloses selection
Browse files Browse the repository at this point in the history
Prior, it was missing the case where the start of the selection came
before the opening brace. We also had an off-by-one error where if the
end of the selection was on the closing brace it would not work.
  • Loading branch information
EpocSquadron committed Aug 6, 2022
1 parent 0cbba03 commit 3aaacfa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion helix-core/src/surround.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ pub fn find_nth_closest_pairs_pos(
match find_nth_pairs_pos(text, ch, range, n) {
// Before we accept this pair, we want to ensure that the
// pair encloses the range rather than just the cursor.
Ok(matching_pair) if matching_pair.1 >= range.to() => {
Ok(matching_pair)
if matching_pair.0 <= pos.saturating_add(1)
&& matching_pair.1 >= range.to().saturating_sub(1) =>
{
return Ok(matching_pair);
}
_ => continue,
Expand Down

0 comments on commit 3aaacfa

Please sign in to comment.