Add terminal colors and clarify elided hierarchy branches
This commit is contained in:
parent
ed1e0595bc
commit
28b7f10f6e
1 changed files with 421 additions and 39 deletions
|
|
@ -1947,13 +1947,16 @@ fn render_hierarchy(
|
|||
while let Some((name, depth, parent)) = stack.pop() {
|
||||
let seen = !included.insert(name.clone());
|
||||
let descendants = children.get(&name).map(Vec::as_slice).unwrap_or(&[]);
|
||||
rows.push((
|
||||
name.clone(),
|
||||
depth,
|
||||
parent,
|
||||
seen,
|
||||
depth >= max_depth && !descendants.is_empty(),
|
||||
));
|
||||
let note = if descendants.is_empty() {
|
||||
""
|
||||
} else if depth >= max_depth {
|
||||
" [children omitted]"
|
||||
} else if seen {
|
||||
" [subtree elided]"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
rows.push((name.clone(), depth, parent, note));
|
||||
if !seen && depth < max_depth {
|
||||
for child in descendants.iter().rev() {
|
||||
stack.push((child.clone(), depth + 1, Some(name.clone())));
|
||||
|
|
@ -1961,7 +1964,7 @@ fn render_hierarchy(
|
|||
}
|
||||
}
|
||||
for name in visible.difference(&reachable) {
|
||||
rows.push((name.clone(), 0, None, false, true));
|
||||
rows.push((name.clone(), 0, None, " [children omitted]"));
|
||||
}
|
||||
let status = |name: &String| {
|
||||
if !old.cells.contains(name) && !new.cells.contains(name) {
|
||||
|
|
@ -2035,7 +2038,7 @@ fn render_hierarchy(
|
|||
if changes.is_none() {
|
||||
new.scope.write_restrictions(&mut out);
|
||||
}
|
||||
for (name, depth, parent, seen, limited) in rows {
|
||||
for (name, depth, parent, note) in rows {
|
||||
out.push_str(&" ".repeat(depth));
|
||||
if direct.contains(&name) {
|
||||
let marker = cell_marker(old.cells.contains(&name), new.cells.contains(&name));
|
||||
|
|
@ -2049,14 +2052,7 @@ fn render_hierarchy(
|
|||
if let Some(parent) = parent {
|
||||
write!(out, " {}", edge_label(&parent, &name)).unwrap();
|
||||
}
|
||||
writeln!(
|
||||
out,
|
||||
"{}{}{}",
|
||||
status(&name),
|
||||
if seen { " [shown above]" } else { "" },
|
||||
if limited { " [children omitted]" } else { "" }
|
||||
)
|
||||
.unwrap();
|
||||
writeln!(out, "{}{note}", status(&name)).unwrap();
|
||||
}
|
||||
if visible.is_empty() {
|
||||
out.push_str("No changed hierarchy\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue