Skip to content

Commit

Permalink
auto pair-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Houkime committed Jul 2, 2022
1 parent 1fde77a commit 55b69fd
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2992,12 +2992,26 @@ pub mod insert {
(start, pos, None) // delete!
}
} else {
// delete char
(
graphemes::nth_prev_grapheme_boundary(text, pos, count),
pos,
None,
)
match (text.get_char(pos.saturating_sub(1)), text.get_char(pos)) {
(Some(_x), Some(_y)) if auto_pairs::DEFAULT_PAIRS.contains(&(_x, _y)) =>
// delete both
{
(
graphemes::nth_prev_grapheme_boundary(text, pos, count),
graphemes::nth_next_grapheme_boundary(text, pos, count),
None,
)
}
_ =>
// delete 1 char
{
(
graphemes::nth_prev_grapheme_boundary(text, pos, count),
pos,
None,
)
}
}
}
});
doc.apply(&transaction, view.id);
Expand Down

0 comments on commit 55b69fd

Please sign in to comment.