mirror of
https://github.com/kristoferssolo/traxor.git
synced 2026-01-14 20:46:14 +00:00
fix: prevent panic when switching to non-existent tab
This commit is contained in:
parent
691e30b4a4
commit
82389ef5b3
@ -124,11 +124,13 @@ impl App {
|
|||||||
self.index = self.index.checked_sub(1).unwrap_or(self.tabs.len() - 1);
|
self.index = self.index.checked_sub(1).unwrap_or(self.tabs.len() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Switches to the tab whose index is `idx`.
|
/// Switches to the tab whose index is `idx` if it exists.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn switch_tab(&mut self, idx: usize) {
|
pub fn switch_tab(&mut self, idx: usize) {
|
||||||
self.close_help();
|
if idx < self.tabs.len() {
|
||||||
self.index = idx;
|
self.close_help();
|
||||||
|
self.index = idx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns current active [`Tab`] number
|
/// Returns current active [`Tab`] number
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user