Skip to content

Commit ab139a1

Browse files
authored
Merge pull request #219 from epage/gap
fix(cli): Give space after each subtree
2 parents 4ff26da + a1eb9ee commit ab139a1

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/bin/git-stack/stack.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,10 +1275,11 @@ impl<'r> Tree<'r> {
12751275
}
12761276
tree.push(stack_tree);
12771277
} else {
1278-
if i != 0 && !stack.is_empty() {
1279-
tree.push(termtree::Tree::root(joint).with_glyphs(SPACE_GLYPHS));
1280-
}
1281-
for child_tree in stack.into_iter() {
1278+
let stack_len = stack.len();
1279+
for (j, child_tree) in stack.into_iter().enumerate() {
1280+
if i != 0 && j == 0 {
1281+
tree.push(termtree::Tree::root(joint).with_glyphs(SPACE_GLYPHS));
1282+
}
12821283
let child = RenderNode {
12831284
repo,
12841285
head_branch,
@@ -1287,17 +1288,23 @@ impl<'r> Tree<'r> {
12871288
palette,
12881289
};
12891290
tree.push(termtree::Tree::root(child).with_glyphs(GLYPHS));
1290-
for child_stack in child_tree.stacks.into_iter() {
1291-
let mut stack_tree = termtree::Tree::root(joint).with_glyphs(JOINT_GLYPHS);
1292-
for child_tree in child_stack.into_iter() {
1293-
stack_tree.push(child_tree.into_display(
1294-
repo,
1295-
head_branch,
1296-
protected_branches,
1297-
palette,
1298-
));
1291+
if !child_tree.stacks.is_empty() {
1292+
for child_stack in child_tree.stacks.into_iter() {
1293+
let mut stack_tree =
1294+
termtree::Tree::root(joint).with_glyphs(JOINT_GLYPHS);
1295+
for child_tree in child_stack.into_iter() {
1296+
stack_tree.push(child_tree.into_display(
1297+
repo,
1298+
head_branch,
1299+
protected_branches,
1300+
palette,
1301+
));
1302+
}
1303+
tree.push(stack_tree);
1304+
}
1305+
if j < stack_len {
1306+
tree.push(termtree::Tree::root(joint).with_glyphs(SPACE_GLYPHS));
12991307
}
1300-
tree.push(stack_tree);
13011308
}
13021309
}
13031310
}

0 commit comments

Comments
 (0)