diff options
author | Gokul Soumya | 2022-04-03 16:30:26 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-04-29 06:51:14 +0000 |
commit | 76175dbd6da4f57118eb52477f3336c6dcab5692 (patch) | |
tree | 47624a5094bc995462db2fbeb1c1d5d7dce2c13a /helix-core | |
parent | de15d7017186cb735cdd31d12510f61a1707d5fb (diff) |
Support m in surround delete and replace
Diffstat (limited to 'helix-core')
-rw-r--r-- | helix-core/src/surround.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/helix-core/src/surround.rs b/helix-core/src/surround.rs index 4cba81bf..6f1fdb95 100644 --- a/helix-core/src/surround.rs +++ b/helix-core/src/surround.rs @@ -212,17 +212,22 @@ fn find_nth_close_pair( /// Find position of surround characters around every cursor. Returns None /// if any positions overlap. Note that the positions are in a flat Vec. /// Use get_surround_pos().chunks(2) to get matching pairs of surround positions. -/// `ch` can be either closing or opening pair. +/// `ch` can be either closing or opening pair. If `ch` is None, surround pairs +/// are automatically detected around each cursor (note that this may result +/// in them selecting different surround characters for each selection). pub fn get_surround_pos( text: RopeSlice, selection: &Selection, - ch: char, + ch: Option<char>, skip: usize, ) -> Result<Vec<usize>> { let mut change_pos = Vec::new(); for &range in selection { - let (open_pos, close_pos) = find_nth_pairs_pos(text, ch, range, skip)?; + let (open_pos, close_pos) = match ch { + Some(ch) => find_nth_pairs_pos(text, ch, range, skip)?, + None => find_nth_closest_pairs_pos(text, range, skip)?, + }; if change_pos.contains(&open_pos) || change_pos.contains(&close_pos) { return Err(Error::CursorOverlap); } |