Skip to content

Commit

Permalink
Fix delete_char_backward for paired characters (helix-editor#4558)
Browse files Browse the repository at this point in the history
When backward-deleting a character, if this character and the following
character form a Pair, we want to delete both. However, there is a bug
that deletes both characters also if both characters are closers of some
Pair.

This commit fixes that by adding an additional check that the deleted
character should be an opener in a Pair.

Closes helix-editor#4544.
  • Loading branch information
ygabuev authored and Frederik Vestre committed Feb 6, 2023
1 parent 6d00cfe commit 67d0279
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,7 @@ pub mod insert {
(Some(_x), Some(_y), Some(ap))
if range.is_single_grapheme(text)
&& ap.get(_x).is_some()
&& ap.get(_x).unwrap().open == _x
&& ap.get(_x).unwrap().close == _y =>
// delete both autopaired characters
{
Expand Down

0 comments on commit 67d0279

Please sign in to comment.