@@ -240,7 +240,7 @@ impl EditorView {
240240 for selection in doc
241241 .selection(view.id)
242242 .iter()
243− .filter(|range| range.overlaps(&screen))
243+ .filter(|range| screen.overlaps(&range))
244244 {
245245 // TODO: render also if only one of the ranges is in viewport
246246 let mut start = view.screen_coords_at_pos(doc, text, selection.anchor);
@@ -261,7 +261,7 @@ impl EditorView {
261261 Rect::new(
262262 viewport.x + start.col as u16,
263263 viewport.y + start.row as u16,
264− (end.col - start.col) as u16 + 1,
264+ ((end.col - start.col) as u16 + 1).min(viewport.width),
265265 1,
266266 ),
267267 selection_style,
@@ -633,6 +633,10 @@ impl Component for EditorView {
633633 // clear with background color
634634 surface.set_style(area, cx.editor.theme.get("ui.background"));
635635
636+ // if the terminal size suddenly changed, we need to trigger a resize
637+ cx.editor
638+ .resize(Rect::new(area.x, area.y, area.width, area.height - 1)); // - 1 to account for commandline
639+
636640 for (view, is_focused) in cx.editor.tree.views() {
637641 let doc = cx.editor.document(view.doc).unwrap();
638642 self.render_view(doc, view, area, surface, &cx.editor.theme, is_focused);