Skip to content

Commit

Permalink
Add command to rotate view backward (helix-editor#5356)
Browse files Browse the repository at this point in the history
  • Loading branch information
mejo13 authored Jan 17, 2023
1 parent 9530fab commit e7e47fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ impl MappableCommand {
swap_view_down, "Swap with split below",
transpose_view, "Transpose splits",
rotate_view, "Goto next window",
rotate_view_reverse, "Goto previous window",
hsplit, "Horizontal bottom split",
hsplit_new, "Horizontal bottom split scratch buffer",
vsplit, "Vertical right split",
Expand Down Expand Up @@ -4317,6 +4318,10 @@ fn rotate_view(cx: &mut Context) {
cx.editor.focus_next()
}

fn rotate_view_reverse(cx: &mut Context) {
cx.editor.focus_prev()
}

fn jump_view_right(cx: &mut Context) {
cx.editor.focus_direction(tree::Direction::Right)
}
Expand Down
4 changes: 4 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,10 @@ impl Editor {
self.focus(self.tree.next());
}

pub fn focus_prev(&mut self) {
self.focus(self.tree.prev());
}

pub fn focus_direction(&mut self, direction: tree::Direction) {
let current_view = self.tree.focus;
if let Some(id) = self.tree.find_split_in_direction(current_view, direction) {
Expand Down

0 comments on commit e7e47fd

Please sign in to comment.