From b474ee1843d5cb7cb5291bee4166490a223e5aac Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 16 Nov 2022 18:59:59 -0600 Subject: Factor out common code for focusing the next view (#4607) There is some common code between Editor::focus_next and Editor::focus that can be eliminated by refactoring Tree::focus_next into a function that only returns the next ViewId.--- helix-view/src/editor.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'helix-view/src/editor.rs') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 4e3a69a2..23e0a497 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1243,16 +1243,7 @@ impl Editor { } pub fn focus_next(&mut self) { - let prev_id = self.tree.focus; - self.tree.focus_next(); - let id = self.tree.focus; - - // if leaving the view: mode should reset and the cursor should be - // within view - if prev_id != id { - self.mode = Mode::Normal; - self.ensure_cursor_in_view(id); - } + self.focus(self.tree.next()); } pub fn focus_direction(&mut self, direction: tree::Direction) { -- cgit v1.2.3-70-g09d2