on master help sign in
Work around rendering errors for positions offscreen.
c70080dBlaž Hrastnik
helix-term/src/ui/editor.rs+18−8
@@ -198,12 +198,16 @@ impl EditorView {
198
198
199 // TODO: paint cursor heads except primary
199 // TODO: paint cursor heads except primary
200
200
201+ // HAXX: we don't render the char if it's offscreen. This should be
202+ // skipped in a better way much earlier
203+ if visual_x < viewport.width {
201− surface.set_string(
204+ surface.set_string(
202− viewport.x + visual_x,
205+ viewport.x + visual_x,
203− viewport.y + line,
206+ viewport.y + line,
204− grapheme,
207+ grapheme,
205− style,
208+ style,
206− );
209+ );
210+ }
207
211
208 visual_x += width;
212 visual_x += width;
209 }
213 }
@@ -268,12 +272,18 @@ impl EditorView {
268
272
269 if let Some(path) = doc.relative_path() {
273 if let Some(path) = doc.relative_path() {
270 let path = path.to_string_lossy();
274 let path = path.to_string_lossy();
271− surface.set_string(viewport.x + 6, viewport.y, path, text_color);
275+ surface.set_stringn(
276+ viewport.x + 6,
277+ viewport.y,
278+ path,
279+ viewport.width.saturating_sub(6) as usize,
280+ text_color,
281+ );
272 // TODO: append [+] if modified
282 // TODO: append [+] if modified
273 }
283 }
274
284
275 surface.set_string(
285 surface.set_string(
276− viewport.x + viewport.width - 10,
286+ viewport.x + viewport.width.saturating_sub(10),
277 viewport.y,
287 viewport.y,
278 format!("{}", doc.diagnostics.len()),
288 format!("{}", doc.diagnostics.len()),
279 text_color,
289 text_color,
helix-view/src/tree.rs+15−4
@@ -152,16 +152,27 @@ impl Tree {
152 match container.layout {
152 match container.layout {
153 Layout::Vertical => unimplemented!(),
153 Layout::Vertical => unimplemented!(),
154 Layout::Horizontal => {
154 Layout::Horizontal => {
155− let len = container.children.len() as u16;
155+ let len = container.children.len();
156
156
157− let width = area.width / len;
157+ let width = area.width / len as u16;
158
158
159 let mut child_x = area.x;
159 let mut child_x = area.x;
160
160
161− for (_i, child) in container.children.iter().enumerate() {
161+ for (i, child) in container.children.iter().enumerate() {
162− let area = Rect::new(child_x, area.y, width, area.height);
162+ let mut area = Rect::new(
163+ child_x,
164+ container.area.y,
165+ width,
166+ container.area.height,
167+ );
163 child_x += width;
168 child_x += width;
164
169
170+ // last child takes the remaining width because we can get uneven
171+ // space from rounding
172+ if i == len - 1 {
173+ area.width = container.area.x + container.area.width - area.x;
174+ }
175+
165 self.stack.push((*child, area));
176 self.stack.push((*child, area));
166 }
177 }
167 }
178 }