editor: Fix cursor shape not restoring when setting removed (#18379)

Closes #18119

Release Notes:

- Fixed the cursor shape in the editor not changing back to default when
`{"cursor_shape": "..."}` setting is removed. (Does not apply to Vim
mode.)
This commit is contained in:
Thorsten Ball 2024-09-26 11:07:07 +02:00 committed by GitHub
parent b701eab44f
commit 2d2e20f9d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 5 deletions

View file

@ -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>) {
self.update_editor(cx, |vim, editor, cx| {
editor.set_cursor_shape(vim.cursor_shape(), cx);
});
}
fn update_editor<S>(
&mut self,
cx: &mut ViewContext<Self>,