diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 23448b43a7cc72cdc3f561383b54101e0bb6acd9..6e5543132c8e7892ad09666e6a733eea535ce634 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -11925,12 +11925,19 @@ impl Editor { )), cx, ); - let editor_settings = EditorSettings::get_global(cx); - if let Some(cursor_shape) = editor_settings.cursor_shape { - self.cursor_shape = cursor_shape; + + let old_cursor_shape = self.cursor_shape; + + { + let editor_settings = EditorSettings::get_global(cx); + self.scroll_manager.vertical_scroll_margin = editor_settings.vertical_scroll_margin; + self.show_breadcrumbs = editor_settings.toolbar.breadcrumbs; + self.cursor_shape = editor_settings.cursor_shape.unwrap_or_default(); + } + + if old_cursor_shape != self.cursor_shape { + cx.emit(EditorEvent::CursorShapeChanged); } - self.scroll_manager.vertical_scroll_margin = editor_settings.vertical_scroll_margin; - self.show_breadcrumbs = editor_settings.toolbar.breadcrumbs; let project_settings = ProjectSettings::get_global(cx); self.serialize_dirty_buffers = project_settings.session.restore_unsaved_buffers; @@ -13127,6 +13134,7 @@ pub enum EditorEvent { TransactionBegun { transaction_id: clock::Lamport, }, + CursorShapeChanged, } impl EventEmitter for Editor {} diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 701972c19bb614a8e8c1ff028a4e19df5971aa46..06116bff99de4863a4c20d491bf19c3a4ce82da4 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -389,6 +389,7 @@ impl Vim { } EditorEvent::Edited { .. } => self.push_to_change_list(cx), EditorEvent::FocusedIn => self.sync_vim_settings(cx), + EditorEvent::CursorShapeChanged => self.cursor_shape_changed(cx), _ => {} } } @@ -679,6 +680,12 @@ impl Vim { }); } + fn cursor_shape_changed(&mut self, cx: &mut ViewContext) { + self.update_editor(cx, |vim, editor, cx| { + editor.set_cursor_shape(vim.cursor_shape(), cx); + }); + } + fn update_editor( &mut self, cx: &mut ViewContext,