diff options
author | Vinegret43 <fvinegret@mail.ru> | 2022-09-17 20:29:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-17 16:29:51 -0400 |
commit | 64eeb5cf1758d80f1d528f4eab6b7fed32b072ef (patch) | |
tree | e74e82f03a68fbd264bd21f8712c37c79c8d38ff /src | |
parent | 362cf4556aebc365d39d41b82f6c815385ad3637 (diff) |
fix bug when HSplit view caused Joshuto to crash (#203)
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/views/tui_hsplit_view.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/ui/views/tui_hsplit_view.rs b/src/ui/views/tui_hsplit_view.rs index d2de9d8..71b483e 100644 --- a/src/ui/views/tui_hsplit_view.rs +++ b/src/ui/views/tui_hsplit_view.rs @@ -138,18 +138,20 @@ impl<'a> Widget for TuiHSplitView<'a> { tab_index - 1 }; - let other_tab_id = tab_context.tab_order[other_tab_index]; - if let Some(curr_tab) = tab_context.tab_ref(&other_tab_id) { - let curr_list = curr_tab.curr_list_ref(); - - let layout_rect = if other_tab_index % 2 == 0 { - layout_rect[0] - } else { - layout_rect[1] - }; + if other_tab_index < tab_context.tab_order.len() { + let other_tab_id = tab_context.tab_order[other_tab_index]; + if let Some(curr_tab) = tab_context.tab_ref(&other_tab_id) { + let curr_list = curr_tab.curr_list_ref(); + + let layout_rect = if other_tab_index % 2 == 0 { + layout_rect[0] + } else { + layout_rect[1] + }; - if let Some(list) = curr_list.as_ref() { - TuiDirListDetailed::new(list, display_options, false).render(layout_rect, buf); + if let Some(list) = curr_list.as_ref() { + TuiDirListDetailed::new(list, display_options, false).render(layout_rect, buf); + } } } } |