@@ -247,6 +247,8 @@ impl MappableCommand {
247 move_prev_long_word_start, "Move to start of previous long word",
247 move_prev_long_word_start, "Move to start of previous long word",
248 move_next_long_word_end, "Move to end of next long word",
248 move_next_long_word_end, "Move to end of next long word",
249 move_prev_long_word_end, "Move to end of previous long word",
249 move_prev_long_word_end, "Move to end of previous long word",
250+ move_parent_node_end, "Move to end of the parent node",
251+ move_parent_node_start, "Move to beginning of the parent node",
250 extend_next_word_start, "Extend to start of next word",
252 extend_next_word_start, "Extend to start of next word",
251 extend_prev_word_start, "Extend to start of previous word",
253 extend_prev_word_start, "Extend to start of previous word",
252 extend_next_word_end, "Extend to end of next word",
254 extend_next_word_end, "Extend to end of next word",
@@ -255,6 +257,8 @@ impl MappableCommand {
255 extend_prev_long_word_start, "Extend to start of previous long word",
257 extend_prev_long_word_start, "Extend to start of previous long word",
256 extend_next_long_word_end, "Extend to end of next long word",
258 extend_next_long_word_end, "Extend to end of next long word",
257 extend_prev_long_word_end, "Extend to end of prev long word",
259 extend_prev_long_word_end, "Extend to end of prev long word",
260+ extend_parent_node_end, "Extend to end of the parent node",
261+ extend_parent_node_start, "Extend to beginning of the parent node",
258 find_till_char, "Move till next occurrence of char",
262 find_till_char, "Move till next occurrence of char",
259 find_next_char, "Move to next occurrence of char",
263 find_next_char, "Move to next occurrence of char",
260 extend_till_char, "Extend till next occurrence of char",
264 extend_till_char, "Extend till next occurrence of char",
@@ -4605,6 +4609,46 @@ fn select_prev_sibling(cx: &mut Context) {
4605 select_sibling_impl(cx, &|node| Node::prev_sibling(&node))
4609 select_sibling_impl(cx, &|node| Node::prev_sibling(&node))
4612+fn move_node_bound_impl(cx: &mut Context, dir: Direction, movement: Movement) {
4613+ let motion = move |editor: &mut Editor| {
4614+ let (view, doc) = current!(editor);
4616+ if let Some(syntax) = doc.syntax() {
4617+ let text = doc.text().slice(..);
4618+ let current_selection = doc.selection(view.id);
4620+ let selection = movement::move_parent_node_end(
4623+ current_selection.clone(),
4628+ doc.set_selection(view.id, selection);
4633+ cx.editor.last_motion = Some(Motion(Box::new(motion)));
4636+pub fn move_parent_node_end(cx: &mut Context) {
4637+ move_node_bound_impl(cx, Direction::Forward, Movement::Move)
4640+pub fn move_parent_node_start(cx: &mut Context) {
4641+ move_node_bound_impl(cx, Direction::Backward, Movement::Move)
4644+pub fn extend_parent_node_end(cx: &mut Context) {
4645+ move_node_bound_impl(cx, Direction::Forward, Movement::Extend)
4648+pub fn extend_parent_node_start(cx: &mut Context) {
4649+ move_node_bound_impl(cx, Direction::Backward, Movement::Extend)
4608fn match_brackets(cx: &mut Context) {
4652fn match_brackets(cx: &mut Context) {
4609 let (view, doc) = current!(cx.editor);
4653 let (view, doc) = current!(cx.editor);
4610 let is_select = cx.editor.mode == Mode::Select;
4654 let is_select = cx.editor.mode == Mode::Select;