summaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorFlorian Gilcher <florian.gilcher@asquera.de>2015-11-04 15:22:51 +0100
committerFlorian Gilcher <florian.gilcher@asquera.de>2015-11-04 15:22:51 +0100
commitd083d26eafe1c5584fef1955209e2aa8b32eb3ae (patch)
tree0044056efa8e5e72a54eea4bf4fab37ea046a4f0 /src/output
parent77fa8974c4cf3117c1c83a5ab41e059336b5a42c (diff)
Fix tree output
Diffstat (limited to 'src/output')
-rw-r--r--src/output/details.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/output/details.rs b/src/output/details.rs
index 49c3fd1..c2bbfc0 100644
--- a/src/output/details.rs
+++ b/src/output/details.rs
@@ -116,6 +116,7 @@ use std::io;
use std::path::PathBuf;
use std::string::ToString;
use std::ops::Add;
+use std::iter::repeat;
use colours::Colours;
use column::{Alignment, Column, Cell};
@@ -683,7 +684,14 @@ impl<U> Table<U> where U: Users {
// necessary to maintain information about the previously-printed
// lines, as the output will change based on whether the
// *previous* entry was the last in its directory.
- stack.reserve(row.depth + 1);
+ // TODO: Replace this by Vec::resize() when it becomes stable (1.5.0)
+ let stack_len = stack.len();
+ if row.depth + 1 > stack_len {
+ stack.extend(repeat(TreePart::Edge).take(row.depth + 1 - stack_len));
+ } else {
+ stack = stack[..(row.depth + 1)].into();
+ }
+
stack[row.depth] = if row.last { TreePart::Corner } else { TreePart::Edge };
for i in 1 .. row.depth + 1 {