summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorDr. David A. Kunz2022-04-03 12:26:46 +0000
committerGitHub2022-04-03 12:26:46 +0000
commit9782204f739813ab5b2dd82451ef2d4695b41d22 (patch)
treedf830fa3053b09861a6ab889a322c0211353c9c2 /helix-term/src/commands.rs
parentec21de08446656b9012c39db2db3d02c7ce3dc9c (diff)
Add typed commands buffer-next and buffer-previous (#1940)
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs19
1 files changed, 9 insertions, 10 deletions
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 != &current);
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 != &current);
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) {