Skip to content

Commit cbb3eba

Browse files
committed
Support ctrl-f and ctrl-b to page up/down, fixes #41
1 parent 0851110 commit cbb3eba

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

helix-term/src/commands.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,10 @@ fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
473473
let last_line = view.last_line(doc);
474474

475475
// clamp into viewport
476-
let line = cursor.row.clamp(
477-
view.first_line + scrolloff,
478-
last_line.saturating_sub(scrolloff),
479-
);
476+
let line = cursor
477+
.row
478+
.min(view.first_line + scrolloff)
479+
.max(last_line.saturating_sub(scrolloff));
480480

481481
let text = doc.text().slice(..);
482482
let pos = pos_at_coords(text, Position::new(line, cursor.col)); // this func will properly truncate to line end

helix-term/src/keymap.rs

+2
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ pub fn default() -> Keymaps {
240240
code: KeyCode::PageUp,
241241
modifiers: KeyModifiers::NONE
242242
} => commands::page_up,
243+
ctrl!('b') => commands::page_up,
243244
KeyEvent {
244245
code: KeyCode::PageDown,
245246
modifiers: KeyModifiers::NONE
246247
} => commands::page_down,
248+
ctrl!('f') => commands::page_down,
247249
ctrl!('u') => commands::half_page_up,
248250
ctrl!('d') => commands::half_page_down,
249251

0 commit comments

Comments
 (0)