aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorGokul Soumya2022-04-03 16:30:26 +0000
committerBlaž Hrastnik2022-04-29 06:51:14 +0000
commit76175dbd6da4f57118eb52477f3336c6dcab5692 (patch)
tree47624a5094bc995462db2fbeb1c1d5d7dce2c13a /helix-term
parentde15d7017186cb735cdd31d12510f61a1707d5fb (diff)
Support m in surround delete and replace
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 75c84b74..54dcc98f 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -4111,15 +4111,16 @@ fn surround_add(cx: &mut Context) {
fn surround_replace(cx: &mut Context) {
let count = cx.count();
cx.on_next_key(move |cx, event| {
- let from = match event.char() {
- Some(from) => from,
+ let surround_ch = match event.char() {
+ Some('m') => None, // m selects the closest surround pair
+ Some(ch) => Some(ch),
None => return,
};
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let selection = doc.selection(view.id);
- let change_pos = match surround::get_surround_pos(text, selection, from, count) {
+ let change_pos = match surround::get_surround_pos(text, selection, surround_ch, count) {
Ok(c) => c,
Err(err) => {
cx.editor.set_error(err.to_string());
@@ -4150,15 +4151,16 @@ fn surround_replace(cx: &mut Context) {
fn surround_delete(cx: &mut Context) {
let count = cx.count();
cx.on_next_key(move |cx, event| {
- let ch = match event.char() {
- Some(ch) => ch,
+ let surround_ch = match event.char() {
+ Some('m') => None, // m selects the closest surround pair
+ Some(ch) => Some(ch),
None => return,
};
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let selection = doc.selection(view.id);
- let change_pos = match surround::get_surround_pos(text, selection, ch, count) {
+ let change_pos = match surround::get_surround_pos(text, selection, surround_ch, count) {
Ok(c) => c,
Err(err) => {
cx.editor.set_error(err.to_string());