diff options
author | Blaž Hrastnik | 2021-06-03 01:28:49 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-03 01:28:49 +0000 |
commit | c0332bd935bb7c016278d43a526e588558a0cab1 (patch) | |
tree | d7a65b8aef3bde84baa7a39196a089e203f95d2a /helix-term/src/ui/editor.rs | |
parent | 3c7729906c9a677d715f2694c16cd78200691aaf (diff) |
Fix split sizes getting out of sync with the terminal size, refs #69
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r-- | helix-term/src/ui/editor.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 47770ebd..e92cf4f1 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -240,7 +240,7 @@ impl EditorView { for selection in doc .selection(view.id) .iter() - .filter(|range| range.overlaps(&screen)) + .filter(|range| screen.overlaps(&range)) { // TODO: render also if only one of the ranges is in viewport let mut start = view.screen_coords_at_pos(doc, text, selection.anchor); @@ -261,7 +261,7 @@ impl EditorView { Rect::new( viewport.x + start.col as u16, viewport.y + start.row as u16, - (end.col - start.col) as u16 + 1, + ((end.col - start.col) as u16 + 1).min(viewport.width), 1, ), selection_style, @@ -633,6 +633,10 @@ impl Component for EditorView { // clear with background color surface.set_style(area, cx.editor.theme.get("ui.background")); + // if the terminal size suddenly changed, we need to trigger a resize + cx.editor + .resize(Rect::new(area.x, area.y, area.width, area.height - 1)); // - 1 to account for commandline + for (view, is_focused) in cx.editor.tree.views() { let doc = cx.editor.document(view.doc).unwrap(); self.render_view(doc, view, area, surface, &cx.editor.theme, is_focused); |