@@ -36,6 +36,7 @@ impl EditorView {
3636 viewport: Rect,
3737 surface: &mut Surface,
3838 theme: &Theme,
39+ is_focused: bool,
3940 ) {
4041 let area = Rect::new(
4142 viewport.x + OFFSET,
@@ -43,14 +44,14 @@ impl EditorView {
4344 viewport.width - OFFSET,
4445 viewport.height - 2,
4546 ); // - 2 for statusline and prompt
46− self.render_buffer(view, area, surface, theme);
47+ self.render_buffer(view, area, surface, theme, is_focused);
4748
4849 // clear with background color
4950 // TODO: this seems to prevent setting style later
5051 // surface.set_style(viewport, theme.get("ui.background"));
5152
5253 let area = Rect::new(viewport.x, viewport.height - 2, viewport.width, 1);
53− self.render_statusline(&view.doc, area, surface, theme);
54+ self.render_statusline(&view.doc, area, surface, theme, is_focused);
5455 }
5556
5657 // TODO: ideally not &mut View but highlights require it because of cursor cache
@@ -60,6 +61,7 @@ impl EditorView {
6061 viewport: Rect,
6162 surface: &mut Surface,
6263 theme: &Theme,
64+ is_focused: bool,
6365 ) {
6466 // TODO: inefficient, should feed chunks.iter() to tree_sitter.parse_with(|offset, pos|)
6567 let source_code = view.doc.text().to_string();
@@ -93,16 +95,20 @@ impl EditorView {
9395 let mut spans = Vec::new();
9496 let mut visual_x = 0;
9597 let mut line = 0u16;
96− let visible_selections: Vec<Range> = view
97− .doc
98− .state
99− .selection()
100− .ranges()
101− .iter()
102− // TODO: limit selection to one in viewport
103− // .filter(|range| !range.is_empty()) // && range.overlaps(&Range::new(start, end + 1))
104− .copied()
105− .collect();
98+ let visible_selections: Vec<Range> = if is_focused {
99+ view.doc
100+ .state
101+ .selection()
102+ .ranges()
103+ .iter()
104+ // TODO: limit selection to one in viewport
105+ // .filter(|range| !range.is_empty()) // && range.overlaps(&Range::new(start, end + 1))
106+ .copied()
107+ .collect()
108+ } else {
109+ // don't render selections on unfocused windows
110+ Vec::new()
111+ };
106112
107113 'outer: for event in highlights {
108114 match event.unwrap() {
@@ -233,6 +239,7 @@ impl EditorView {
233239 viewport: Rect,
234240 surface: &mut Surface,
235241 theme: &Theme,
242+ is_focused: bool,
236243 ) {
237244 let text_color = text_color();
238245 let mode = match doc.mode() {
@@ -322,9 +329,9 @@ impl Component for EditorView {
322329 // SAFETY: we cheat around the view_mut() borrow because it doesn't allow us to also borrow
323330 // theme. Theme is immutable mutating view won't disrupt theme_ref.
324331 let theme_ref = unsafe { &*(&cx.editor.theme as *const Theme) };
325− for view in cx.editor.tree.views() {
332+ for (view, is_focused) in cx.editor.tree.views() {
326333 // TODO: use parent area
327− self.render_view(view, view.area, surface, theme_ref);
334+ self.render_view(view, view.area, surface, theme_ref, is_focused);
328335 }
329336
330337 // TODO: drop unwrap