diff options
author | Blaž Hrastnik | 2021-02-05 05:42:56 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-02-05 05:42:56 +0000 |
commit | c70080dd686738ab6272dd0b3c421c6621e86e34 (patch) | |
tree | fcb8c5733124ff1ce6ecfcc773bb635c9a489424 /helix-term | |
parent | 8f0ddf9632068a28cc09b32c84cfec9093b73104 (diff) |
Work around rendering errors for positions offscreen.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/ui/editor.rs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 090f3d0b..18e853f6 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -198,12 +198,16 @@ impl EditorView { // TODO: paint cursor heads except primary - surface.set_string( - viewport.x + visual_x, - viewport.y + line, - grapheme, - style, - ); + // HAXX: we don't render the char if it's offscreen. This should be + // skipped in a better way much earlier + if visual_x < viewport.width { + surface.set_string( + viewport.x + visual_x, + viewport.y + line, + grapheme, + style, + ); + } visual_x += width; } @@ -268,12 +272,18 @@ impl EditorView { if let Some(path) = doc.relative_path() { let path = path.to_string_lossy(); - surface.set_string(viewport.x + 6, viewport.y, path, text_color); + surface.set_stringn( + viewport.x + 6, + viewport.y, + path, + viewport.width.saturating_sub(6) as usize, + text_color, + ); // TODO: append [+] if modified } surface.set_string( - viewport.x + viewport.width - 10, + viewport.x + viewport.width.saturating_sub(10), viewport.y, format!("{}", doc.diagnostics.len()), text_color, |