ratatui_toolkit/widgets/code_diff/extensions/file_tree/methods/selected_path.rs
1//! Method for getting the path of the selected item.
2
3use crate::widgets::code_diff::diff_file_tree::DiffFileTree;
4
5impl DiffFileTree {
6 /// Returns the full path of the currently selected item.
7 ///
8 /// # Returns
9 ///
10 /// `Some(path)` if an item is selected, `None` if the tree is empty.
11 #[must_use]
12 pub fn selected_path(&self) -> Option<String> {
13 let path = self.state.selected_path.as_ref()?;
14 let node = self.get_node_at_path(path)?;
15 Some(node.data.full_path.clone())
16 }
17}