mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: adjust offset value after resizing window (#1458)
This commit is contained in:
parent
598104492b
commit
ebb4aef84f
1 changed files with 13 additions and 0 deletions
|
|
@ -73,6 +73,7 @@ impl Folder {
|
|||
};
|
||||
|
||||
self.sync_page(false);
|
||||
self.adjust_offset();
|
||||
self.tracing |= b;
|
||||
b
|
||||
}
|
||||
|
|
@ -103,6 +104,18 @@ impl Folder {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn adjust_offset(&mut self) {
|
||||
let len = self.files.len();
|
||||
let limit = LAYOUT.load().current.height as usize;
|
||||
let scrolloff = (limit / 2).min(MANAGER.scrolloff as usize);
|
||||
let max_offset = (self.offset + limit).saturating_sub(scrolloff).min(len);
|
||||
|
||||
let new_offset =
|
||||
if self.cursor >= max_offset { self.cursor - limit + scrolloff } else { self.offset };
|
||||
|
||||
self.offset = new_offset.min(len.saturating_sub(limit));
|
||||
}
|
||||
|
||||
fn next(&mut self, step: Step) -> bool {
|
||||
let old = (self.cursor, self.offset);
|
||||
let len = self.files.len();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue