Rename model based variable names to entity (#24198)

## Context
While looking through the client crate, I noticed that some of the old
functions and variables were still using gpui::model name that was
deprecated during the gpui3 transition. This PR renames those instances
of model to entity to be more inline with gpui3.

In addition, I also renamed `model` to `entity` in cases found by the
below search terms given by @someone13574

- model = cx.
- model: Entity
- model: &Entity
- OpenedModelHandle
- model.update
- model.upgrade
- model = .*\.root (regex)
- parent_model
- model = cx.new
- cx.spawn(move |model

Release Notes:

- N/A
This commit is contained in:
Anthony Eid 2025-02-04 13:24:35 -05:00 committed by GitHub
parent 27d1c689cf
commit 8c7096f7a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 332 additions and 327 deletions

View file

@ -173,7 +173,7 @@ pub fn init(cx: &mut App) {
.and_then(|item| item.act_as::<Editor>(cx))
.and_then(|editor| editor.read(cx).addon::<VimAddon>().cloned());
let Some(vim) = vim else { return };
vim.model.update(cx, |_, cx| {
vim.entity.update(cx, |_, cx| {
cx.defer_in(window, |vim, window, cx| vim.search_submit(window, cx))
})
});
@ -183,12 +183,12 @@ pub fn init(cx: &mut App) {
#[derive(Clone)]
pub(crate) struct VimAddon {
pub(crate) model: Entity<Vim>,
pub(crate) entity: Entity<Vim>,
}
impl editor::Addon for VimAddon {
fn extend_key_context(&self, key_context: &mut KeyContext, cx: &App) {
self.model.read(cx).extend_key_context(key_context, cx)
self.entity.read(cx).extend_key_context(key_context, cx)
}
fn to_any(&self) -> &dyn std::any::Any {
@ -298,7 +298,7 @@ impl Vim {
if toggle {
let is_relative = editor
.addon::<VimAddon>()
.map(|vim| vim.model.read(cx).mode != Mode::Insert);
.map(|vim| vim.entity.read(cx).mode != Mode::Insert);
editor.set_relative_line_number(is_relative, cx)
} else {
editor.set_relative_line_number(None, cx)
@ -324,7 +324,9 @@ impl Vim {
fn activate(editor: &mut Editor, window: &mut Window, cx: &mut Context<Editor>) {
let vim = Vim::new(window, cx);
editor.register_addon(VimAddon { model: vim.clone() });
editor.register_addon(VimAddon {
entity: vim.clone(),
});
vim.update(cx, |_, cx| {
Vim::action(editor, cx, |vim, action: &SwitchMode, window, cx| {