@@ -4111,15 +4111,16 @@ fn surround_add(cx: &mut Context) {
4111fn surround_replace(cx: &mut Context) {
4111fn surround_replace(cx: &mut Context) {
4112 let count = cx.count();
4112 let count = cx.count();
4113 cx.on_next_key(move |cx, event| {
4113 cx.on_next_key(move |cx, event| {
4114− let from = match event.char() {
4114+ let surround_ch = match event.char() {
4115− Some(from) => from,
4115+ Some('m') => None, // m selects the closest surround pair
4116+ Some(ch) => Some(ch),
4116 None => return,
4117 None => return,
4118 let (view, doc) = current!(cx.editor);
4119 let (view, doc) = current!(cx.editor);
4119 let text = doc.text().slice(..);
4120 let text = doc.text().slice(..);
4120 let selection = doc.selection(view.id);
4121 let selection = doc.selection(view.id);
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) {
4123 Ok(c) => c,
4124 Ok(c) => c,
4124 Err(err) => {
4125 Err(err) => {
4125 cx.editor.set_error(err.to_string());
4126 cx.editor.set_error(err.to_string());
@@ -4150,15 +4151,16 @@ fn surround_replace(cx: &mut Context) {
4150fn surround_delete(cx: &mut Context) {
4151fn surround_delete(cx: &mut Context) {
4151 let count = cx.count();
4152 let count = cx.count();
4152 cx.on_next_key(move |cx, event| {
4153 cx.on_next_key(move |cx, event| {
4153− let ch = match event.char() {
4154+ let surround_ch = match event.char() {
4155+ Some('m') => None, // m selects the closest surround pair
4154− Some(ch) => ch,
4156+ Some(ch) => Some(ch),
4155 None => return,
4157 None => return,
4157 let (view, doc) = current!(cx.editor);
4159 let (view, doc) = current!(cx.editor);
4158 let text = doc.text().slice(..);
4160 let text = doc.text().slice(..);
4159 let selection = doc.selection(view.id);
4161 let selection = doc.selection(view.id);
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) {
4162 Ok(c) => c,
4164 Ok(c) => c,
4163 Err(err) => {
4165 Err(err) => {
4164 cx.editor.set_error(err.to_string());
4166 cx.editor.set_error(err.to_string());