Build the tree prefix (vertical bars and connectors) for a node.
(&self, visitor: &CollectionVisitor, node_idx: usize, node_depth: usize)
| 168 | |
| 169 | /// Build the tree prefix (vertical bars and connectors) for a node. |
| 170 | fn build_prefix(&self, visitor: &CollectionVisitor, node_idx: usize, node_depth: usize) -> String { |
| 171 | let mut prefix = String::new(); |
| 172 | |
| 173 | // For each ancestor level, determine if we need a vertical bar |
| 174 | for d in 0..node_depth.saturating_sub(1) { |
| 175 | let ancestor_idx = visitor.find_ancestor_at_depth(node_idx, d + 1); |
| 176 | let show_bar = ancestor_idx.is_none_or(|idx| !visitor.is_last_child(idx)); |
| 177 | prefix.push_str(if show_bar { "│ " } else { " " }); |
| 178 | } |
| 179 | |
| 180 | // Add the connector for this node |
| 181 | let connector = if visitor.is_last_child(node_idx) { "╰─ " } else { "├─ " }; |
| 182 | prefix.push_str(connector); |
| 183 | |
| 184 | prefix |
| 185 | } |
| 186 | } |
no test coverage detected