feat: tab switch wraparound (#160)

This commit is contained in:
Ctem 2023-09-17 17:50:16 +09:00 committed by sxyazi
parent 07d5df05f1
commit ba3f603de4
No known key found for this signature in database

View File

@ -33,7 +33,11 @@ impl Tabs {
}
pub fn switch(&mut self, idx: isize, rel: bool) -> bool {
let idx = if rel { self.absolute(idx) } else { idx as usize };
let idx = if rel {
(self.idx as isize + idx).rem_euclid(self.items.len() as isize) as usize
} else {
idx as usize
};
if idx == self.idx || idx >= self.items.len() {
return false;