From 3541a1175ff30dc40701b5df28e6c32b44fd1cea Mon Sep 17 00:00:00 2001 From: Omer Tuchfeld Date: Thu, 11 Jul 2024 20:47:10 +0200 Subject: [PATCH] Disrupt blink for immediate feedback on cursor shape changes (#14177) # Issue When a user does something that changes the cursor shape, such as when switching between vim modes, there may be an up to 500ms (cursor blink interval) delay until the user receives feedback for their action. This happens when the shape change happens during the invisible phase of a blink - the user will not see the cursor shape change until the next phase, which could be 500ms away. # Solution Cursor shape changes should disrupt blinking by forcing the cursor to be shown, this results in immediate feedback for shape changes. This is in line with the behavior of other editors I've tried. Release Notes: - Improved visual feedback when changing cursor shape --- crates/editor/src/editor.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index ddeb8e3add..595593e843 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2163,6 +2163,10 @@ impl Editor { pub fn set_cursor_shape(&mut self, cursor_shape: CursorShape, cx: &mut ViewContext) { self.cursor_shape = cursor_shape; + + // Disrupt blink for immediate user feedback that the cursor shape has changed + self.blink_manager.update(cx, BlinkManager::show_cursor); + cx.notify(); }