on master help sign in
Adjust `m` textobject description and minor code clarification (#3343)
7711db3Daniel S Poulin
helix-core/src/textobject.rs+6−6
@@ -198,26 +198,26 @@ pub fn textobject_paragraph(
198 Range::new(anchor, head)
198 Range::new(anchor, head)
199}
199}
200
200
201−pub fn textobject_surround(
201+pub fn textobject_pair_surround(
202 slice: RopeSlice,
202 slice: RopeSlice,
203 range: Range,
203 range: Range,
204 textobject: TextObject,
204 textobject: TextObject,
205 ch: char,
205 ch: char,
206 count: usize,
206 count: usize,
207) -> Range {
207) -> Range {
208− textobject_surround_impl(slice, range, textobject, Some(ch), count)
208+ textobject_pair_surround_impl(slice, range, textobject, Some(ch), count)
209}
209}
210
210
211−pub fn textobject_surround_closest(
211+pub fn textobject_pair_surround_closest(
212 slice: RopeSlice,
212 slice: RopeSlice,
213 range: Range,
213 range: Range,
214 textobject: TextObject,
214 textobject: TextObject,
215 count: usize,
215 count: usize,
216) -> Range {
216) -> Range {
217− textobject_surround_impl(slice, range, textobject, None, count)
217+ textobject_pair_surround_impl(slice, range, textobject, None, count)
218}
218}
219
219
220−fn textobject_surround_impl(
220+fn textobject_pair_surround_impl(
221 slice: RopeSlice,
221 slice: RopeSlice,
222 range: Range,
222 range: Range,
223 textobject: TextObject,
223 textobject: TextObject,
@@ -562,7 +562,7 @@ mod test {
562 let slice = doc.slice(..);
562 let slice = doc.slice(..);
563 for &case in scenario {
563 for &case in scenario {
564 let (pos, objtype, expected_range, ch, count) = case;
564 let (pos, objtype, expected_range, ch, count) = case;
565− let result = textobject_surround(slice, Range::point(pos), objtype, ch, count);
565+ let result = textobject_pair_surround(slice, Range::point(pos), objtype, ch, count);
566 assert_eq!(
566 assert_eq!(
567 result,
567 result,
568 expected_range.into(),
568 expected_range.into(),
helix-term/src/commands.rs+5−3
@@ -4332,10 +4332,12 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
4332 'o' => textobject_treesitter("comment", range),
4332 'o' => textobject_treesitter("comment", range),
4333 't' => textobject_treesitter("test", range),
4333 't' => textobject_treesitter("test", range),
4334 'p' => textobject::textobject_paragraph(text, range, objtype, count),
4334 'p' => textobject::textobject_paragraph(text, range, objtype, count),
4335+ 'm' => textobject::textobject_pair_surround_closest(
4335− 'm' => textobject::textobject_surround_closest(text, range, objtype, count),
4336+ text, range, objtype, count,
4337+ ),
4336 // TODO: cancel new ranges if inconsistent surround matches across lines
4338 // TODO: cancel new ranges if inconsistent surround matches across lines
4337 ch if !ch.is_ascii_alphanumeric() => {
4339 ch if !ch.is_ascii_alphanumeric() => {
4338− textobject::textobject_surround(text, range, objtype, ch, count)
4340+ textobject::textobject_pair_surround(text, range, objtype, ch, count)
4339 }
4341 }
4340 _ => range,
4342 _ => range,
4341 }
4343 }
@@ -4361,7 +4363,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
4361 ("a", "Argument/parameter (tree-sitter)"),
4363 ("a", "Argument/parameter (tree-sitter)"),
4362 ("o", "Comment (tree-sitter)"),
4364 ("o", "Comment (tree-sitter)"),
4363 ("t", "Test (tree-sitter)"),
4365 ("t", "Test (tree-sitter)"),
4364− ("m", "Matching delimiter under cursor"),
4366+ ("m", "Closest surrounding pair to cursor"),
4365 (" ", "... or any character acting as a pair"),
4367 (" ", "... or any character acting as a pair"),
4366 ];
4368 ];
4367
4369