@@ -4111,15 +4111,16 @@ fn surround_add(cx: &mut Context) {
41114111fn surround_replace(cx: &mut Context) {
41124112 let count = cx.count();
41134113 cx.on_next_key(move |cx, event| {
4114− let from = match event.char() {
4115− Some(from) => from,
4114+ let surround_ch = match event.char() {
4115+ Some('m') => None, // m selects the closest surround pair
4116+ Some(ch) => Some(ch),
41164117 None => return,
41174118 };
41184119 let (view, doc) = current!(cx.editor);
41194120 let text = doc.text().slice(..);
41204121 let selection = doc.selection(view.id);
41214122
4122− let change_pos = match surround::get_surround_pos(text, selection, from, count) {
4123+ let change_pos = match surround::get_surround_pos(text, selection, surround_ch, count) {
41234124 Ok(c) => c,
41244125 Err(err) => {
41254126 cx.editor.set_error(err.to_string());
@@ -4150,15 +4151,16 @@ fn surround_replace(cx: &mut Context) {
41504151fn surround_delete(cx: &mut Context) {
41514152 let count = cx.count();
41524153 cx.on_next_key(move |cx, event| {
4153− let ch = match event.char() {
4154− Some(ch) => ch,
4154+ let surround_ch = match event.char() {
4155+ Some('m') => None, // m selects the closest surround pair
4156+ Some(ch) => Some(ch),
41554157 None => return,
41564158 };
41574159 let (view, doc) = current!(cx.editor);
41584160 let text = doc.text().slice(..);
41594161 let selection = doc.selection(view.id);
41604162
4161− let change_pos = match surround::get_surround_pos(text, selection, ch, count) {
4163+ let change_pos = match surround::get_surround_pos(text, selection, surround_ch, count) {
41624164 Ok(c) => c,
41634165 Err(err) => {
41644166 cx.editor.set_error(err.to_string());