From 1d23c05aee4ff4bcc50115f9c24d0e2cd6717193 Mon Sep 17 00:00:00 2001 From: Daniel Khodyrev Date: Sun, 19 Jan 2025 18:11:50 +0700 Subject: [PATCH] fix: #391 [Editor] cursor always blinks even when not in focus --- src/views/editor/view.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/views/editor/view.rs b/src/views/editor/view.rs index f2b62199..a18a095b 100644 --- a/src/views/editor/view.rs +++ b/src/views/editor/view.rs @@ -724,6 +724,7 @@ impl EditorView { pub fn paint_text( cx: &mut PaintCx, + view_id: &ViewId, ed: &Editor, viewport: Rect, is_active: bool, @@ -761,7 +762,10 @@ impl EditorView { } } - Self::paint_cursor_caret(cx, ed, is_active, screen_lines); + let is_cursor_visible = cx.app_state.is_focused(view_id); + if (is_cursor_visible) { + Self::paint_cursor_caret(cx, ed, is_active, screen_lines); + } for (line, y) in screen_lines.iter_lines_y() { let text_layout = ed.text_layout(line); @@ -897,6 +901,7 @@ impl View for EditorView { let screen_lines = ed.screen_lines.get_untracked(); EditorView::paint_text( cx, + &self.id(), &ed, viewport, self.is_active.get_untracked(),