ratatui_toolkit/widgets/file_system_tree/methods/
select_next.rs

1use crate::primitives::tree_view::TreeViewState;
2use crate::widgets::file_system_tree::FileSystemTree;
3
4impl<'a> FileSystemTree<'a> {
5    pub fn select_next(&mut self, state: &mut TreeViewState) {
6        let visible_paths = self.get_visible_paths(state);
7        if visible_paths.is_empty() {
8            return;
9        }
10
11        if let Some(current_path) = &state.selected_path {
12            if let Some(current_idx) = visible_paths.iter().position(|p| p == current_path) {
13                if current_idx < visible_paths.len() - 1 {
14                    state.select(visible_paths[current_idx + 1].clone());
15                }
16            }
17        } else {
18            state.select(visible_paths[0].clone());
19        }
20    }
21}