@@ -441,35 +441,35 @@ fn goto_first_nonwhitespace(cx: &mut Context) {
441 doc.set_selection(view.id, selection);
441 doc.set_selection(view.id, selection);
444−fn goto_window_top(cx: &mut Context) {
444+fn goto_window(cx: &mut Context, align: Align) {
445 let (view, doc) = current!(cx.editor);
445 let (view, doc) = current!(cx.editor);
447 let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
447 let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
448− let line = (view.first_line + scrolloff).min(view.last_line(doc).saturating_sub(scrolloff));
449− let pos = doc.text().line_to_char(line);
451− doc.set_selection(view.id, Selection::point(pos));
449+ let last_line = view.last_line(doc);
454−fn goto_window_middle(cx: &mut Context) {
451+ let line = match align {
455− let (view, doc) = current!(cx.editor);
452+ Align::Top => (view.first_line + scrolloff),
453+ Align::Center => (view.first_line + (view.area.height as usize / 2)),
454+ Align::Bottom => last_line.saturating_sub(scrolloff),
456+ .min(last_line.saturating_sub(scrolloff));
457− let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
458− let line = view.first_line + (view.area.height as usize / 2);
459− let line = line.min(view.last_line(doc).saturating_sub(scrolloff));
460 let pos = doc.text().line_to_char(line);
458 let pos = doc.text().line_to_char(line);
462 doc.set_selection(view.id, Selection::point(pos));
460 doc.set_selection(view.id, Selection::point(pos));
465−fn goto_window_bottom(cx: &mut Context) {
463+fn goto_window_top(cx: &mut Context) {
466− let (view, doc) = current!(cx.editor);
464+ goto_window(cx, Align::Top)
468− let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
467+fn goto_window_middle(cx: &mut Context) {
469− let line = view.last_line(doc).saturating_sub(scrolloff);
468+ goto_window(cx, Align::Center)
470− let pos = doc.text().line_to_char(line);
469+}
472− doc.set_selection(view.id, Selection::point(pos));
471+fn goto_window_bottom(cx: &mut Context) {
472+ goto_window(cx, Align::Bottom)
475// TODO: move vs extend could take an extra type Extend/Move that would
475// TODO: move vs extend could take an extra type Extend/Move that would
@@ -3722,7 +3722,7 @@ mode_info! {
3722 "i" => goto_implementation,
3722 "i" => goto_implementation,
3723 /// window top
3723 /// window top
3724 "t" => goto_window_top,
3724 "t" => goto_window_top,
3725− /// window center
3725+ /// window middle
3726 "m" => goto_window_middle,
3726 "m" => goto_window_middle,
3727 /// window bottom
3727 /// window bottom
3728 "b" => goto_window_bottom,
3728 "b" => goto_window_bottom,