Skip to content

Commit 9cbc060

Browse files
committed
Fix #67: Commit parent outside scope
1 parent 7f34f9a commit 9cbc060

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/print/svg.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ pub fn print_svg(graph: &GitGraph, settings: &Settings) -> Result<String, String
4242
continue;
4343
};
4444
let Some(par_idx) = graph.indices.get(&par_oid) else {
45+
// Parent is outside scope of graph.indices
46+
// so draw a vertical line to the bottom
47+
let idx_bottom = max_idx;
48+
document = document.add(line(
49+
idx,
50+
branch.visual.column.unwrap(),
51+
idx_bottom,
52+
branch.visual.column.unwrap(),
53+
branch_color,
54+
));
4555
continue;
4656
};
4757
let par_info = &graph.commits[*par_idx];

src/print/unicode.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ pub fn print_unicode(graph: &GitGraph, settings: &Settings) -> Result<UnicodeGra
163163
continue;
164164
};
165165
let Some(par_idx) = graph.indices.get(&par_oid) else {
166+
// Parent is outside scope of graph.indices
167+
// so draw a vertical line to the bottom
168+
let idx_bottom = grid.height;
169+
vline(
170+
&mut grid,
171+
(idx_map, idx_bottom),
172+
column,
173+
branch_color,
174+
branch.persistence,
175+
);
166176
continue;
167177
};
168178

@@ -800,6 +810,7 @@ impl GridCell {
800810
/// This can be rendered as unicode text or as SVG.
801811
struct Grid {
802812
width: usize,
813+
height: usize,
803814

804815
/// Grid cells are stored in row-major order.
805816
data: Vec<GridCell>,
@@ -809,6 +820,7 @@ impl Grid {
809820
pub fn new(width: usize, height: usize, initial: GridCell) -> Self {
810821
Grid {
811822
width,
823+
height,
812824
data: vec![initial; width * height],
813825
}
814826
}

0 commit comments

Comments
 (0)