From 3853826f78296ebce7c565d9fbae2bf2426a3936 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 27 Jan 2022 16:33:47 +0100 Subject: [PATCH] Pause cursor blinking only when editor is focused Co-Authored-By: Nathan Sobo --- crates/editor/src/editor.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 26d7f2f87506e2e43f708a3949ae4c763f621ea4..9827be2f6e81db70ef2eff86ea14e61c7a16cdb8 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3493,9 +3493,11 @@ impl Editor { fn set_selections(&mut self, selections: Arc<[Selection]>, cx: &mut ViewContext) { self.selections = selections; - self.buffer.update(cx, |buffer, cx| { - buffer.set_active_selections(&self.selections, cx) - }); + if self.focused { + self.buffer.update(cx, |buffer, cx| { + buffer.set_active_selections(&self.selections, cx) + }); + } } pub fn request_autoscroll(&mut self, autoscroll: Autoscroll, cx: &mut ViewContext) { @@ -3721,6 +3723,10 @@ impl Editor { } fn pause_cursor_blinking(&mut self, cx: &mut ViewContext) { + if !self.focused { + return; + } + self.show_local_cursors = true; cx.notify();