mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: adjust_offset subtract overflow
This commit is contained in:
parent
ebb4aef84f
commit
839a43a6ee
1 changed files with 6 additions and 3 deletions
|
|
@ -108,10 +108,13 @@ impl Folder {
|
||||||
let len = self.files.len();
|
let len = self.files.len();
|
||||||
let limit = LAYOUT.load().current.height as usize;
|
let limit = LAYOUT.load().current.height as usize;
|
||||||
let scrolloff = (limit / 2).min(MANAGER.scrolloff as usize);
|
let scrolloff = (limit / 2).min(MANAGER.scrolloff as usize);
|
||||||
let max_offset = (self.offset + limit).saturating_sub(scrolloff).min(len);
|
let max_offset = (self.offset + limit).min(len).saturating_sub(scrolloff);
|
||||||
|
|
||||||
let new_offset =
|
let new_offset = if self.cursor >= max_offset {
|
||||||
if self.cursor >= max_offset { self.cursor - limit + scrolloff } else { self.offset };
|
self.cursor.saturating_sub(limit) + scrolloff
|
||||||
|
} else {
|
||||||
|
self.offset
|
||||||
|
};
|
||||||
|
|
||||||
self.offset = new_offset.min(len.saturating_sub(limit));
|
self.offset = new_offset.min(len.saturating_sub(limit));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue