use super::*;
impl FileTree {
#[cfg(test)]
pub fn visible_indices(&self) -> Vec<usize> {
(0..self.nodes.len()).collect()
}
#[cfg(test)]
pub fn sticky_rows_for_test(&self) -> Vec<(u16, usize)> {
(self.last_inner.y..).zip(self.sticky.drawn_at()).collect()
}
pub fn sticky_row_at(&self, y: u16) -> Option<usize> {
let line = self.line_at_y(y)?;
self.sticky.now(line, self.nodes.len(), |i, path| {
self.nodes[i].path == *path
})
}
}
pub(crate) fn sticky_ancestors(nodes: &[Node], top_idx: usize, max: usize) -> Vec<usize> {
let Some(top) = nodes.get(top_idx) else {
return Vec::new();
};
let mut chain = Vec::new();
let mut want_depth = top.depth;
for i in (0..top_idx).rev() {
if want_depth == 0 {
break;
}
if nodes[i].depth < want_depth {
chain.push(i);
want_depth = nodes[i].depth;
}
}
chain.reverse(); let skip = chain.len().saturating_sub(max);
chain.split_off(skip)
}