From 9782204f739813ab5b2dd82451ef2d4695b41d22 Mon Sep 17 00:00:00 2001 From: Dr. David A. Kunz Date: Sun, 3 Apr 2022 14:26:46 +0200 Subject: Add typed commands buffer-next and buffer-previous (#1940) --- helix-term/src/commands.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'helix-term/src/commands.rs') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index f0fb469b..b93cfc41 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -637,36 +637,35 @@ fn goto_line_start(cx: &mut Context) { } fn goto_next_buffer(cx: &mut Context) { - goto_buffer(cx, Direction::Forward); + goto_buffer(cx.editor, Direction::Forward); } fn goto_previous_buffer(cx: &mut Context) { - goto_buffer(cx, Direction::Backward); + goto_buffer(cx.editor, Direction::Backward); } -fn goto_buffer(cx: &mut Context, direction: Direction) { - let current = view!(cx.editor).doc; +fn goto_buffer(editor: &mut Editor, direction: Direction) { + let current = view!(editor).doc; let id = match direction { Direction::Forward => { - let iter = cx.editor.documents.keys(); + let iter = editor.documents.keys(); let mut iter = iter.skip_while(|id| *id != ¤t); iter.next(); // skip current item - iter.next().or_else(|| cx.editor.documents.keys().next()) + iter.next().or_else(|| editor.documents.keys().next()) } Direction::Backward => { - let iter = cx.editor.documents.keys(); + let iter = editor.documents.keys(); let mut iter = iter.rev().skip_while(|id| *id != ¤t); iter.next(); // skip current item - iter.next() - .or_else(|| cx.editor.documents.keys().rev().next()) + iter.next().or_else(|| editor.documents.keys().rev().next()) } } .unwrap(); let id = *id; - cx.editor.switch(id, Action::Replace); + editor.switch(id, Action::Replace); } fn extend_to_line_start(cx: &mut Context) { -- cgit v1.2.3-70-g09d2