From e7e47fd54263fb46f2dbb6fe8954fa489d143752 Mon Sep 17 00:00:00 2001 From: mejo13 <36098293+mejo13@users.noreply.github.com> Date: Tue, 17 Jan 2023 23:15:21 +0100 Subject: [PATCH] Add command to rotate view backward (#5356) --- helix-term/src/commands.rs | 5 +++++ helix-view/src/editor.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 7df53a48a..15e4b47b2 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -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", @@ -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) } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 547a4ffbd..4a44a00cb 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -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) {