From c70080dd686738ab6272dd0b3c421c6621e86e34 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 5 Feb 2021 14:42:56 +0900 Subject: Work around rendering errors for positions offscreen. --- helix-view/src/tree.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'helix-view/src') diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs index 100d8a54..784fea3f 100644 --- a/helix-view/src/tree.rs +++ b/helix-view/src/tree.rs @@ -152,16 +152,27 @@ impl Tree { match container.layout { Layout::Vertical => unimplemented!(), Layout::Horizontal => { - let len = container.children.len() as u16; + let len = container.children.len(); - let width = area.width / len; + let width = area.width / len as u16; let mut child_x = area.x; - for (_i, child) in container.children.iter().enumerate() { - let area = Rect::new(child_x, area.y, width, area.height); + for (i, child) in container.children.iter().enumerate() { + let mut area = Rect::new( + child_x, + container.area.y, + width, + container.area.height, + ); child_x += width; + // last child takes the remaining width because we can get uneven + // space from rounding + if i == len - 1 { + area.width = container.area.x + container.area.width - area.x; + } + self.stack.push((*child, area)); } } -- cgit v1.2.3-70-g09d2