diff options
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3dba9333..7b30168a 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -473,10 +473,10 @@ fn scroll(cx: &mut Context, offset: usize, direction: Direction) { let last_line = view.last_line(doc); // clamp into viewport - let line = cursor.row.clamp( - view.first_line + scrolloff, - last_line.saturating_sub(scrolloff), - ); + let line = cursor + .row + .min(view.first_line + scrolloff) + .max(last_line.saturating_sub(scrolloff)); let text = doc.text().slice(..); let pos = pos_at_coords(text, Position::new(line, cursor.col)); // this func will properly truncate to line end @@ -1031,6 +1031,9 @@ pub fn command_mode(cx: &mut Context) { } let parts = input.split_ascii_whitespace().collect::<Vec<&str>>(); + if parts.is_empty() { + return; + } if let Some(cmd) = cmd::COMMANDS.get(parts[0]) { (cmd.fun)(editor, &parts[1..], event); |