|
|
@ -799,28 +799,29 @@ fn goto_line_start(cx: &mut Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn goto_next_buffer(cx: &mut Context) {
|
|
|
|
fn goto_next_buffer(cx: &mut Context) {
|
|
|
|
goto_buffer(cx.editor, Direction::Forward);
|
|
|
|
goto_buffer(cx.editor, Direction::Forward, cx.count());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn goto_previous_buffer(cx: &mut Context) {
|
|
|
|
fn goto_previous_buffer(cx: &mut Context) {
|
|
|
|
goto_buffer(cx.editor, Direction::Backward);
|
|
|
|
goto_buffer(cx.editor, Direction::Backward, cx.count());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn goto_buffer(editor: &mut Editor, direction: Direction) {
|
|
|
|
fn goto_buffer(editor: &mut Editor, direction: Direction, count: usize) {
|
|
|
|
let current = view!(editor).doc;
|
|
|
|
let current = view!(editor).doc;
|
|
|
|
|
|
|
|
|
|
|
|
let id = match direction {
|
|
|
|
let id = match direction {
|
|
|
|
Direction::Forward => {
|
|
|
|
Direction::Forward => {
|
|
|
|
let iter = editor.documents.keys();
|
|
|
|
let iter = editor.documents.keys();
|
|
|
|
let mut iter = iter.skip_while(|id| *id != ¤t);
|
|
|
|
// skip 'count' times past current buffer
|
|
|
|
iter.next(); // skip current item
|
|
|
|
iter.cycle().skip_while(|id| *id != ¤t).nth(count)
|
|
|
|
iter.next().or_else(|| editor.documents.keys().next())
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Direction::Backward => {
|
|
|
|
Direction::Backward => {
|
|
|
|
let iter = editor.documents.keys();
|
|
|
|
let iter = editor.documents.keys();
|
|
|
|
let mut iter = iter.rev().skip_while(|id| *id != ¤t);
|
|
|
|
// skip 'count' times past current buffer
|
|
|
|
iter.next(); // skip current item
|
|
|
|
iter.rev()
|
|
|
|
iter.next().or_else(|| editor.documents.keys().next_back())
|
|
|
|
.cycle()
|
|
|
|
|
|
|
|
.skip_while(|id| *id != ¤t)
|
|
|
|
|
|
|
|
.nth(count)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|