From fa9e17306c1d00cc251816b20f56b336e78872ca Mon Sep 17 00:00:00 2001 From: Xerxes-2 Date: Wed, 26 Jun 2024 20:06:44 +1000 Subject: [PATCH] apply this feature to moving forward --- yazi-core/src/input/commands/move_.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yazi-core/src/input/commands/move_.rs b/yazi-core/src/input/commands/move_.rs index 441ac127..6a261951 100644 --- a/yazi-core/src/input/commands/move_.rs +++ b/yazi-core/src/input/commands/move_.rs @@ -39,8 +39,13 @@ impl Input { )); let (limit, snap) = (self.limit(), self.snap_mut()); - if snap.offset > snap.cursor.saturating_sub(limit / 2) { - snap.offset = snap.cursor.saturating_sub(limit / 2); + let half_limit = limit / 2; + let max_offset = snap.cursor.saturating_sub(half_limit); + let min_offset = max_offset.min(snap.len().saturating_sub(limit)); + if snap.offset > max_offset { + snap.offset = max_offset; + } else if snap.offset < min_offset { + snap.offset = min_offset; } else if snap.value.is_empty() { snap.offset = 0; } else {