Remove more references to 'model' in GPUI APIs (#23693)

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2025-01-26 20:00:27 -08:00 committed by GitHub
parent a6b1514246
commit 9cae96f82f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
115 changed files with 309 additions and 311 deletions

View file

@ -473,7 +473,7 @@ impl Render for ActivityIndicator {
let Some(content) = self.content_to_render(cx) else { let Some(content) = self.content_to_render(cx) else {
return result; return result;
}; };
let this = cx.model().downgrade(); let this = cx.entity().downgrade();
let truncate_content = content.message.len() > MAX_MESSAGE_LEN; let truncate_content = content.message.len() > MAX_MESSAGE_LEN;
result.gap_2().child( result.gap_2().child(
PopoverMenu::new("activity-indicator-popover") PopoverMenu::new("activity-indicator-popover")

View file

@ -155,7 +155,7 @@ impl AssistantPanel {
let project_paths = if let Some(tab) = dropped_item.downcast_ref::<DraggedTab>() let project_paths = if let Some(tab) = dropped_item.downcast_ref::<DraggedTab>()
{ {
if tab.pane == cx.model() { if tab.pane == cx.entity() {
return None; return None;
} }
let item = tab.pane.read(cx).item_for_index(tab.ix); let item = tab.pane.read(cx).item_for_index(tab.ix);
@ -231,7 +231,7 @@ impl AssistantPanel {
pane.active_item() pane.active_item()
.map_or(false, |item| item.downcast::<ContextHistory>().is_some()), .map_or(false, |item| item.downcast::<ContextHistory>().is_some()),
); );
let _pane = cx.model().clone(); let _pane = cx.entity().clone();
let right_children = h_flex() let right_children = h_flex()
.gap(DynamicSpacing::Base02.rems(cx)) .gap(DynamicSpacing::Base02.rems(cx))
.child( .child(
@ -617,7 +617,7 @@ impl AssistantPanel {
InlineAssistant::update_global(cx, |assistant, cx| { InlineAssistant::update_global(cx, |assistant, cx| {
assistant.assist( assistant.assist(
&active_editor, &active_editor,
Some(cx.model().downgrade()), Some(cx.entity().downgrade()),
include_context.then_some(&assistant_panel), include_context.then_some(&assistant_panel),
initial_prompt, initial_prompt,
window, window,
@ -629,7 +629,7 @@ impl AssistantPanel {
TerminalInlineAssistant::update_global(cx, |assistant, cx| { TerminalInlineAssistant::update_global(cx, |assistant, cx| {
assistant.assist( assistant.assist(
&active_terminal, &active_terminal,
Some(cx.model().downgrade()), Some(cx.entity().downgrade()),
Some(&assistant_panel), Some(&assistant_panel),
initial_prompt, initial_prompt,
window, window,

View file

@ -77,7 +77,7 @@ pub fn init(
let Some(window) = window else { let Some(window) = window else {
return; return;
}; };
let workspace = cx.model().clone(); let workspace = cx.entity().clone();
InlineAssistant::update_global(cx, |inline_assistant, cx| { InlineAssistant::update_global(cx, |inline_assistant, cx| {
inline_assistant.register_workspace(&workspace, window, cx) inline_assistant.register_workspace(&workspace, window, cx)
}); });
@ -211,7 +211,7 @@ impl InlineAssistant {
} else { } else {
editor.add_code_action_provider( editor.add_code_action_provider(
Rc::new(AssistantCodeActionProvider { Rc::new(AssistantCodeActionProvider {
editor: cx.model().downgrade(), editor: cx.entity().downgrade(),
workspace: workspace.downgrade(), workspace: workspace.downgrade(),
}), }),
window, window,
@ -1345,7 +1345,7 @@ impl EditorInlineAssists {
}) })
}), }),
editor.update(cx, |editor, cx| { editor.update(cx, |editor, cx| {
let editor_handle = cx.model().downgrade(); let editor_handle = cx.entity().downgrade();
editor.register_action(move |_: &editor::actions::Newline, window, cx| { editor.register_action(move |_: &editor::actions::Newline, window, cx| {
InlineAssistant::update_global(cx, |this, cx| { InlineAssistant::update_global(cx, |this, cx| {
if let Some(editor) = editor_handle.upgrade() { if let Some(editor) = editor_handle.upgrade() {
@ -1355,7 +1355,7 @@ impl EditorInlineAssists {
}) })
}), }),
editor.update(cx, |editor, cx| { editor.update(cx, |editor, cx| {
let editor_handle = cx.model().downgrade(); let editor_handle = cx.entity().downgrade();
editor.register_action(move |_: &editor::actions::Cancel, window, cx| { editor.register_action(move |_: &editor::actions::Cancel, window, cx| {
InlineAssistant::update_global(cx, |this, cx| { InlineAssistant::update_global(cx, |this, cx| {
if let Some(editor) = editor_handle.upgrade() { if let Some(editor) = editor_handle.upgrade() {

View file

@ -242,7 +242,7 @@ impl TerminalInlineAssistant {
let (latest_output, working_directory) = assist let (latest_output, working_directory) = assist
.terminal .terminal
.update(cx, |terminal, cx| { .update(cx, |terminal, cx| {
let terminal = terminal.model().read(cx); let terminal = terminal.entity().read(cx);
let latest_output = terminal.last_n_non_empty_lines(DEFAULT_CONTEXT_LINES); let latest_output = terminal.last_n_non_empty_lines(DEFAULT_CONTEXT_LINES);
let working_directory = terminal let working_directory = terminal
.working_directory() .working_directory()

View file

@ -56,7 +56,7 @@ impl ActiveThread {
messages: Vec::new(), messages: Vec::new(),
rendered_messages_by_id: HashMap::default(), rendered_messages_by_id: HashMap::default(),
list_state: ListState::new(0, ListAlignment::Bottom, px(1024.), { list_state: ListState::new(0, ListAlignment::Bottom, px(1024.), {
let this = cx.model().downgrade(); let this = cx.entity().downgrade();
move |ix, _: &mut Window, cx: &mut App| { move |ix, _: &mut Window, cx: &mut App| {
this.update(cx, |this, cx| this.render_message(ix, cx)) this.update(cx, |this, cx| this.render_message(ix, cx))
.unwrap() .unwrap()

View file

@ -158,7 +158,7 @@ impl AssistantPanel {
let project = workspace.project().clone(); let project = workspace.project().clone();
let language_registry = project.read(cx).languages().clone(); let language_registry = project.read(cx).languages().clone();
let workspace = workspace.weak_handle(); let workspace = workspace.weak_handle();
let weak_self = cx.model().downgrade(); let weak_self = cx.entity().downgrade();
let message_editor = cx.new(|cx| { let message_editor = cx.new(|cx| {
MessageEditor::new( MessageEditor::new(
@ -811,7 +811,7 @@ impl AssistantPanel {
.child(v_flex().mx_auto().w_4_5().gap_2().children( .child(v_flex().mx_auto().w_4_5().gap_2().children(
recent_threads.into_iter().map(|thread| { recent_threads.into_iter().map(|thread| {
// TODO: keyboard navigation // TODO: keyboard navigation
PastThread::new(thread, cx.model().downgrade(), false) PastThread::new(thread, cx.entity().downgrade(), false)
}), }),
)) ))
.child( .child(

View file

@ -78,7 +78,7 @@ impl ContextPicker {
} }
fn build_menu(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Entity<ContextMenu> { fn build_menu(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Entity<ContextMenu> {
let context_picker = cx.model().clone(); let context_picker = cx.entity().clone();
let menu = ContextMenu::build(window, cx, move |menu, _window, cx| { let menu = ContextMenu::build(window, cx, move |menu, _window, cx| {
let recent = self.recent_entries(cx); let recent = self.recent_entries(cx);
@ -144,7 +144,7 @@ impl ContextPicker {
} }
fn select_kind(&mut self, kind: ContextKind, window: &mut Window, cx: &mut Context<Self>) { fn select_kind(&mut self, kind: ContextKind, window: &mut Window, cx: &mut Context<Self>) {
let context_picker = cx.model().downgrade(); let context_picker = cx.entity().downgrade();
match kind { match kind {
ContextKind::File => { ContextKind::File => {

View file

@ -393,7 +393,7 @@ impl Render for ContextStrip {
.on_action(cx.listener(Self::remove_focused_context)) .on_action(cx.listener(Self::remove_focused_context))
.on_action(cx.listener(Self::accept_suggested_context)) .on_action(cx.listener(Self::accept_suggested_context))
.on_children_prepainted({ .on_children_prepainted({
let model = cx.model().downgrade(); let model = cx.entity().downgrade();
move |children_bounds, _window, cx| { move |children_bounds, _window, cx| {
model model
.update(cx, |this, _| { .update(cx, |this, _| {

View file

@ -58,7 +58,7 @@ pub fn init(
let Some(window) = window else { let Some(window) = window else {
return; return;
}; };
let workspace = cx.model().clone(); let workspace = cx.entity().clone();
InlineAssistant::update_global(cx, |inline_assistant, cx| { InlineAssistant::update_global(cx, |inline_assistant, cx| {
inline_assistant.register_workspace(&workspace, window, cx) inline_assistant.register_workspace(&workspace, window, cx)
}); });
@ -196,7 +196,7 @@ impl InlineAssistant {
editor.add_code_action_provider( editor.add_code_action_provider(
Rc::new(AssistantCodeActionProvider { Rc::new(AssistantCodeActionProvider {
editor: cx.model().downgrade(), editor: cx.entity().downgrade(),
workspace: workspace.downgrade(), workspace: workspace.downgrade(),
thread_store, thread_store,
}), }),
@ -249,7 +249,7 @@ impl InlineAssistant {
InlineAssistant::update_global(cx, |assistant, cx| { InlineAssistant::update_global(cx, |assistant, cx| {
assistant.assist( assistant.assist(
&active_editor, &active_editor,
cx.model().downgrade(), cx.entity().downgrade(),
thread_store, thread_store,
window, window,
cx, cx,
@ -260,7 +260,7 @@ impl InlineAssistant {
TerminalInlineAssistant::update_global(cx, |assistant, cx| { TerminalInlineAssistant::update_global(cx, |assistant, cx| {
assistant.assist( assistant.assist(
&active_terminal, &active_terminal,
cx.model().downgrade(), cx.entity().downgrade(),
thread_store, thread_store,
window, window,
cx, cx,
@ -1472,7 +1472,7 @@ impl EditorInlineAssists {
}) })
}), }),
editor.update(cx, |editor, cx| { editor.update(cx, |editor, cx| {
let editor_handle = cx.model().downgrade(); let editor_handle = cx.entity().downgrade();
editor.register_action(move |_: &editor::actions::Newline, window, cx| { editor.register_action(move |_: &editor::actions::Newline, window, cx| {
InlineAssistant::update_global(cx, |this, cx| { InlineAssistant::update_global(cx, |this, cx| {
if let Some(editor) = editor_handle.upgrade() { if let Some(editor) = editor_handle.upgrade() {
@ -1482,7 +1482,7 @@ impl EditorInlineAssists {
}) })
}), }),
editor.update(cx, |editor, cx| { editor.update(cx, |editor, cx| {
let editor_handle = cx.model().downgrade(); let editor_handle = cx.entity().downgrade();
editor.register_action(move |_: &editor::actions::Cancel, window, cx| { editor.register_action(move |_: &editor::actions::Cancel, window, cx| {
InlineAssistant::update_global(cx, |this, cx| { InlineAssistant::update_global(cx, |this, cx| {
if let Some(editor) = editor_handle.upgrade() { if let Some(editor) = editor_handle.upgrade() {

View file

@ -222,7 +222,7 @@ impl TerminalInlineAssistant {
let (latest_output, working_directory) = assist let (latest_output, working_directory) = assist
.terminal .terminal
.update(cx, |terminal, cx| { .update(cx, |terminal, cx| {
let terminal = terminal.model().read(cx); let terminal = terminal.entity().read(cx);
let latest_output = terminal.last_n_non_empty_lines(DEFAULT_CONTEXT_LINES); let latest_output = terminal.last_n_non_empty_lines(DEFAULT_CONTEXT_LINES);
let working_directory = terminal let working_directory = terminal
.working_directory() .working_directory()

View file

@ -154,7 +154,7 @@ impl Render for ThreadHistory {
} else { } else {
history.child( history.child(
uniform_list( uniform_list(
cx.model().clone(), cx.entity().clone(),
"thread-history", "thread-history",
threads.len(), threads.len(),
move |history, range, _window, _cx| { move |history, range, _window, _cx| {

View file

@ -213,7 +213,7 @@ impl ContextEditor {
) -> Self { ) -> Self {
let completion_provider = SlashCommandCompletionProvider::new( let completion_provider = SlashCommandCompletionProvider::new(
context.read(cx).slash_commands().clone(), context.read(cx).slash_commands().clone(),
Some(cx.model().downgrade()), Some(cx.entity().downgrade()),
Some(workspace.clone()), Some(workspace.clone()),
); );
@ -551,7 +551,7 @@ impl ContextEditor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
let context_editor = cx.model().downgrade(); let context_editor = cx.entity().downgrade();
match event { match event {
ContextEvent::MessagesEdited => { ContextEvent::MessagesEdited => {
@ -605,7 +605,7 @@ impl ContextEditor {
.map(|tool_use| { .map(|tool_use| {
let placeholder = FoldPlaceholder { let placeholder = FoldPlaceholder {
render: render_fold_icon_button( render: render_fold_icon_button(
cx.model().downgrade(), cx.entity().downgrade(),
IconName::PocketKnife, IconName::PocketKnife,
tool_use.name.clone().into(), tool_use.name.clone().into(),
), ),
@ -789,7 +789,7 @@ impl ContextEditor {
let placeholder = FoldPlaceholder { let placeholder = FoldPlaceholder {
render: render_fold_icon_button( render: render_fold_icon_button(
cx.model().downgrade(), cx.entity().downgrade(),
IconName::PocketKnife, IconName::PocketKnife,
format!("Tool Result: {tool_use_id}").into(), format!("Tool Result: {tool_use_id}").into(),
), ),
@ -937,7 +937,7 @@ impl ContextEditor {
window: &mut Window, window: &mut Window,
cx: &mut Context<ContextEditor>, cx: &mut Context<ContextEditor>,
) { ) {
let this = cx.model().downgrade(); let this = cx.entity().downgrade();
let mut editors_to_close = Vec::new(); let mut editors_to_close = Vec::new();
self.editor.update(cx, |editor, cx| { self.editor.update(cx, |editor, cx| {
@ -1081,7 +1081,7 @@ impl ContextEditor {
start..end, start..end,
FoldPlaceholder { FoldPlaceholder {
render: render_fold_icon_button( render: render_fold_icon_button(
cx.model().downgrade(), cx.entity().downgrade(),
section.icon, section.icon,
section.label.clone(), section.label.clone(),
), ),
@ -1843,7 +1843,7 @@ impl ContextEditor {
editor.insert("\n", window, cx); editor.insert("\n", window, cx);
let fold_placeholder = let fold_placeholder =
quote_selection_fold_placeholder(crease_title, cx.model().downgrade()); quote_selection_fold_placeholder(crease_title, cx.entity().downgrade());
let crease = Crease::inline( let crease = Crease::inline(
anchor_before..anchor_after, anchor_before..anchor_after,
fold_placeholder, fold_placeholder,
@ -2027,7 +2027,7 @@ impl ContextEditor {
let buffer = editor.buffer().read(cx).snapshot(cx); let buffer = editor.buffer().read(cx).snapshot(cx);
let mut buffer_rows_to_fold = BTreeSet::new(); let mut buffer_rows_to_fold = BTreeSet::new();
let weak_editor = cx.model().downgrade(); let weak_editor = cx.entity().downgrade();
editor.insert_creases( editor.insert_creases(
metadata.creases.into_iter().map(|metadata| { metadata.creases.into_iter().map(|metadata| {
let start = buffer.anchor_after( let start = buffer.anchor_after(
@ -2509,7 +2509,7 @@ impl ContextEditor {
fn render_inject_context_menu(&self, cx: &mut Context<Self>) -> impl IntoElement { fn render_inject_context_menu(&self, cx: &mut Context<Self>) -> impl IntoElement {
slash_command_picker::SlashCommandSelector::new( slash_command_picker::SlashCommandSelector::new(
self.slash_commands.clone(), self.slash_commands.clone(),
cx.model().downgrade(), cx.entity().downgrade(),
Button::new("trigger", "Add Context") Button::new("trigger", "Add Context")
.icon(IconName::Plus) .icon(IconName::Plus)
.icon_size(IconSize::Small) .icon_size(IconSize::Small)
@ -3699,7 +3699,7 @@ pub fn make_lsp_adapter_delegate(
Ok(Some(LocalLspAdapterDelegate::new( Ok(Some(LocalLspAdapterDelegate::new(
project.languages().clone(), project.languages().clone(),
project.environment(), project.environment(),
cx.weak_model(), cx.weak_entity(),
&worktree, &worktree,
http_client, http_client,
project.fs().clone(), project.fs().clone(),

View file

@ -318,7 +318,7 @@ impl ContextStore {
.client .client
.subscribe_to_entity(remote_id) .subscribe_to_entity(remote_id)
.log_err() .log_err()
.map(|subscription| subscription.set_model(&cx.model(), &mut cx.to_async())); .map(|subscription| subscription.set_model(&cx.entity(), &mut cx.to_async()));
self.advertise_contexts(cx); self.advertise_contexts(cx);
} else { } else {
self.client_subscription = None; self.client_subscription = None;

View file

@ -85,7 +85,7 @@ impl SlashCommand for TerminalSlashCommand {
let lines = active_terminal let lines = active_terminal
.read(cx) .read(cx)
.model() .entity()
.read(cx) .read(cx)
.last_n_non_empty_lines(line_count); .last_n_non_empty_lines(line_count);

View file

@ -152,7 +152,7 @@ impl ToolbarItemView for Breadcrumbs {
return ToolbarItemLocation::Hidden; return ToolbarItemLocation::Hidden;
}; };
let this = cx.model().downgrade(); let this = cx.entity().downgrade();
self.subscription = Some(item.subscribe_to_item_events( self.subscription = Some(item.subscribe_to_item_events(
window, window,
cx, cx,

View file

@ -105,8 +105,8 @@ impl ActiveCall {
incoming_call: watch::channel(), incoming_call: watch::channel(),
_join_debouncer: OneAtATime { cancel: None }, _join_debouncer: OneAtATime { cancel: None },
_subscriptions: vec![ _subscriptions: vec![
client.add_request_handler(cx.weak_model(), Self::handle_incoming_call), client.add_request_handler(cx.weak_entity(), Self::handle_incoming_call),
client.add_message_handler(cx.weak_model(), Self::handle_call_canceled), client.add_message_handler(cx.weak_entity(), Self::handle_call_canceled),
], ],
client, client,
user_store, user_store,

View file

@ -148,7 +148,7 @@ impl Room {
pending_participants: Default::default(), pending_participants: Default::default(),
pending_call_count: 0, pending_call_count: 0,
client_subscriptions: vec![ client_subscriptions: vec![
client.add_message_handler(cx.weak_model(), Self::handle_room_updated) client.add_message_handler(cx.weak_entity(), Self::handle_room_updated)
], ],
_subscriptions: vec![ _subscriptions: vec![
cx.on_release(Self::released), cx.on_release(Self::released),

View file

@ -98,8 +98,8 @@ impl ActiveCall {
incoming_call: watch::channel(), incoming_call: watch::channel(),
_join_debouncer: OneAtATime { cancel: None }, _join_debouncer: OneAtATime { cancel: None },
_subscriptions: vec![ _subscriptions: vec![
client.add_request_handler(cx.weak_model(), Self::handle_incoming_call), client.add_request_handler(cx.weak_entity(), Self::handle_incoming_call),
client.add_message_handler(cx.weak_model(), Self::handle_call_canceled), client.add_message_handler(cx.weak_entity(), Self::handle_call_canceled),
], ],
client, client,
user_store, user_store,

View file

@ -204,7 +204,7 @@ impl Room {
pending_participants: Default::default(), pending_participants: Default::default(),
pending_call_count: 0, pending_call_count: 0,
client_subscriptions: vec![ client_subscriptions: vec![
client.add_message_handler(cx.weak_model(), Self::handle_room_updated) client.add_message_handler(cx.weak_entity(), Self::handle_room_updated)
], ],
_subscriptions: vec![ _subscriptions: vec![
cx.on_release(Self::released), cx.on_release(Self::released),

View file

@ -81,7 +81,7 @@ impl ChannelBuffer {
collaborators: Default::default(), collaborators: Default::default(),
acknowledge_task: None, acknowledge_task: None,
channel_id: channel.id, channel_id: channel.id,
subscription: Some(subscription.set_model(&cx.model(), &mut cx.to_async())), subscription: Some(subscription.set_model(&cx.entity(), &mut cx.to_async())),
user_store, user_store,
channel_store, channel_store,
}; };

View file

@ -132,7 +132,7 @@ impl ChannelChat {
last_acknowledged_id: None, last_acknowledged_id: None,
rng: StdRng::from_entropy(), rng: StdRng::from_entropy(),
first_loaded_message_id: None, first_loaded_message_id: None,
_subscription: subscription.set_model(&cx.model(), &mut cx.to_async()), _subscription: subscription.set_model(&cx.entity(), &mut cx.to_async()),
} }
})?; })?;
Self::handle_loaded_messages( Self::handle_loaded_messages(

View file

@ -158,8 +158,8 @@ impl ChannelStore {
pub fn new(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut Context<Self>) -> Self { pub fn new(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut Context<Self>) -> Self {
let rpc_subscriptions = [ let rpc_subscriptions = [
client.add_message_handler(cx.weak_model(), Self::handle_update_channels), client.add_message_handler(cx.weak_entity(), Self::handle_update_channels),
client.add_message_handler(cx.weak_model(), Self::handle_update_user_channels), client.add_message_handler(cx.weak_entity(), Self::handle_update_user_channels),
]; ];
let mut connection_status = client.status(); let mut connection_status = client.status();
@ -306,7 +306,7 @@ impl ChannelStore {
) -> Task<Result<Entity<ChannelBuffer>>> { ) -> Task<Result<Entity<ChannelBuffer>>> {
let client = self.client.clone(); let client = self.client.clone();
let user_store = self.user_store.clone(); let user_store = self.user_store.clone();
let channel_store = cx.model(); let channel_store = cx.entity();
self.open_channel_resource( self.open_channel_resource(
channel_id, channel_id,
|this| &mut this.opened_buffers, |this| &mut this.opened_buffers,
@ -436,7 +436,7 @@ impl ChannelStore {
) -> Task<Result<Entity<ChannelChat>>> { ) -> Task<Result<Entity<ChannelChat>>> {
let client = self.client.clone(); let client = self.client.clone();
let user_store = self.user_store.clone(); let user_store = self.user_store.clone();
let this = cx.model(); let this = cx.entity();
self.open_channel_resource( self.open_channel_resource(
channel_id, channel_id,
|this| &mut this.opened_chats, |this| &mut this.opened_chats,

View file

@ -146,10 +146,10 @@ impl UserStore {
let (mut current_user_tx, current_user_rx) = watch::channel(); let (mut current_user_tx, current_user_rx) = watch::channel();
let (update_contacts_tx, mut update_contacts_rx) = mpsc::unbounded(); let (update_contacts_tx, mut update_contacts_rx) = mpsc::unbounded();
let rpc_subscriptions = vec![ let rpc_subscriptions = vec![
client.add_message_handler(cx.weak_model(), Self::handle_update_plan), client.add_message_handler(cx.weak_entity(), Self::handle_update_plan),
client.add_message_handler(cx.weak_model(), Self::handle_update_contacts), client.add_message_handler(cx.weak_entity(), Self::handle_update_contacts),
client.add_message_handler(cx.weak_model(), Self::handle_update_invite_info), client.add_message_handler(cx.weak_entity(), Self::handle_update_invite_info),
client.add_message_handler(cx.weak_model(), Self::handle_show_contacts), client.add_message_handler(cx.weak_entity(), Self::handle_show_contacts),
]; ];
Self { Self {
users: Default::default(), users: Default::default(),
@ -262,7 +262,7 @@ impl UserStore {
Ok(()) Ok(())
}), }),
pending_contact_requests: Default::default(), pending_contact_requests: Default::default(),
weak_self: cx.weak_model(), weak_self: cx.weak_entity(),
} }
} }

View file

@ -91,7 +91,7 @@ async fn test_host_disconnect(
) )
}); });
let cx_b = &mut VisualTestContext::from_window(*workspace_b, cx_b); let cx_b = &mut VisualTestContext::from_window(*workspace_b, cx_b);
let workspace_b_view = workspace_b.root_model(cx_b).unwrap(); let workspace_b_view = workspace_b.root(cx_b).unwrap();
let editor_b = workspace_b let editor_b = workspace_b
.update(cx_b, |workspace, window, cx| { .update(cx_b, |workspace, window, cx| {

View file

@ -21,14 +21,14 @@ async fn test_notifications(
let notification_events_b = Arc::new(Mutex::new(Vec::new())); let notification_events_b = Arc::new(Mutex::new(Vec::new()));
client_a.notification_store().update(cx_a, |_, cx| { client_a.notification_store().update(cx_a, |_, cx| {
let events = notification_events_a.clone(); let events = notification_events_a.clone();
cx.subscribe(&cx.model(), move |_, _, event, _| { cx.subscribe(&cx.entity(), move |_, _, event, _| {
events.lock().push(event.clone()); events.lock().push(event.clone());
}) })
.detach() .detach()
}); });
client_b.notification_store().update(cx_b, |_, cx| { client_b.notification_store().update(cx_b, |_, cx| {
let events = notification_events_b.clone(); let events = notification_events_b.clone();
cx.subscribe(&cx.model(), move |_, _, event, _| { cx.subscribe(&cx.entity(), move |_, _, event, _| {
events.lock().push(event.clone()); events.lock().push(event.clone());
}) })
.detach() .detach()

View file

@ -849,7 +849,7 @@ impl TestClient {
) -> (Entity<Workspace>, &'a mut VisualTestContext) { ) -> (Entity<Workspace>, &'a mut VisualTestContext) {
let window = cx.update(|cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap()); let window = cx.update(|cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap());
let model = window.root_model(cx).unwrap(); let model = window.root(cx).unwrap();
let cx = VisualTestContext::from_window(*window.deref(), cx).as_mut(); let cx = VisualTestContext::from_window(*window.deref(), cx).as_mut();
// it might be nice to try and cleanup these at the end of each test. // it might be nice to try and cleanup these at the end of each test.
(model, cx) (model, cx)
@ -861,7 +861,7 @@ pub fn open_channel_notes(
cx: &mut VisualTestContext, cx: &mut VisualTestContext,
) -> Task<anyhow::Result<Entity<ChannelView>>> { ) -> Task<anyhow::Result<Entity<ChannelView>>> {
let window = cx.update(|_, cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap()); let window = cx.update(|_, cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap());
let model = window.root_model(cx).unwrap(); let model = window.root(cx).unwrap();
cx.update(|window, cx| ChannelView::open(channel_id, None, model.clone(), window, cx)) cx.update(|window, cx| ChannelView::open(channel_id, None, model.clone(), window, cx))
} }

View file

@ -204,7 +204,7 @@ impl ChannelView {
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let buffer = channel_buffer.read(cx).buffer(); let buffer = channel_buffer.read(cx).buffer();
let this = cx.model().downgrade(); let this = cx.entity().downgrade();
let editor = cx.new(|cx| { let editor = cx.new(|cx| {
let mut editor = Editor::for_buffer(buffer, None, window, cx); let mut editor = Editor::for_buffer(buffer, None, window, cx);
editor.set_collaboration_hub(Box::new(ChannelBufferCollaborationHub( editor.set_collaboration_hub(Box::new(ChannelBufferCollaborationHub(

View file

@ -97,7 +97,7 @@ impl ChatPanel {
}); });
cx.new(|cx| { cx.new(|cx| {
let model = cx.model().downgrade(); let model = cx.entity().downgrade();
let message_list = ListState::new( let message_list = ListState::new(
0, 0,
gpui::ListAlignment::Bottom, gpui::ListAlignment::Bottom,
@ -680,7 +680,7 @@ impl ChatPanel {
}) })
}) })
.when_some(message_id, |el, message_id| { .when_some(message_id, |el, message_id| {
let this = cx.model().clone(); let this = cx.entity().clone();
el.child( el.child(
self.render_popover_button( self.render_popover_button(

View file

@ -101,7 +101,7 @@ impl MessageEditor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let this = cx.model().downgrade(); let this = cx.entity().downgrade();
editor.update(cx, |editor, cx| { editor.update(cx, |editor, cx| {
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx); editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
editor.set_use_autoclose(false); editor.set_use_autoclose(false);

View file

@ -73,7 +73,7 @@ pub fn init(cx: &mut App) {
.and_then(|room| room.read(cx).channel_id()); .and_then(|room| room.read(cx).channel_id());
if let Some(channel_id) = channel_id { if let Some(channel_id) = channel_id {
let workspace = cx.model().clone(); let workspace = cx.entity().clone();
window.defer(cx, move |window, cx| { window.defer(cx, move |window, cx| {
ChannelView::open(channel_id, None, workspace, window, cx) ChannelView::open(channel_id, None, workspace, window, cx)
.detach_and_log_err(cx) .detach_and_log_err(cx)
@ -239,7 +239,7 @@ impl CollabPanel {
) )
.detach(); .detach();
let model = cx.model().downgrade(); let model = cx.entity().downgrade();
let list_state = ListState::new( let list_state = ListState::new(
0, 0,
gpui::ListAlignment::Top, gpui::ListAlignment::Top,
@ -1040,7 +1040,7 @@ impl CollabPanel {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
let this = cx.model().clone(); let this = cx.entity().clone();
if !(role == proto::ChannelRole::Guest if !(role == proto::ChannelRole::Guest
|| role == proto::ChannelRole::Talker || role == proto::ChannelRole::Talker
|| role == proto::ChannelRole::Member) || role == proto::ChannelRole::Member)
@ -1170,7 +1170,7 @@ impl CollabPanel {
.channel_for_id(clipboard.channel_id) .channel_for_id(clipboard.channel_id)
.map(|channel| channel.name.clone()) .map(|channel| channel.name.clone())
}); });
let this = cx.model().clone(); let this = cx.entity().clone();
let context_menu = ContextMenu::build(window, cx, |mut context_menu, window, cx| { let context_menu = ContextMenu::build(window, cx, |mut context_menu, window, cx| {
if self.has_subchannels(ix) { if self.has_subchannels(ix) {
@ -1337,7 +1337,7 @@ impl CollabPanel {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
let this = cx.model().clone(); let this = cx.entity().clone();
let in_room = ActiveCall::global(cx).read(cx).room().is_some(); let in_room = ActiveCall::global(cx).read(cx).room().is_some();
let context_menu = ContextMenu::build(window, cx, |mut context_menu, _, _| { let context_menu = ContextMenu::build(window, cx, |mut context_menu, _, _| {

View file

@ -40,7 +40,7 @@ impl ChannelModal {
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
cx.observe(&channel_store, |_, _, cx| cx.notify()).detach(); cx.observe(&channel_store, |_, _, cx| cx.notify()).detach();
let channel_modal = cx.model().downgrade(); let channel_modal = cx.entity().downgrade();
let picker = cx.new(|cx| { let picker = cx.new(|cx| {
Picker::uniform_list( Picker::uniform_list(
ChannelModalDelegate { ChannelModalDelegate {
@ -581,7 +581,7 @@ impl ChannelModalDelegate {
return; return;
}; };
let user_id = membership.user.id; let user_id = membership.user.id;
let picker = cx.model().clone(); let picker = cx.entity().clone();
let context_menu = ContextMenu::build(window, cx, |mut menu, _window, _cx| { let context_menu = ContextMenu::build(window, cx, |mut menu, _window, _cx| {
let role = membership.role; let role = membership.role;

View file

@ -16,7 +16,7 @@ pub struct ContactFinder {
impl ContactFinder { impl ContactFinder {
pub fn new(user_store: Entity<UserStore>, window: &mut Window, cx: &mut Context<Self>) -> Self { pub fn new(user_store: Entity<UserStore>, window: &mut Window, cx: &mut Context<Self>) -> Self {
let delegate = ContactFinderDelegate { let delegate = ContactFinderDelegate {
parent: cx.model().downgrade(), parent: cx.entity().downgrade(),
user_store, user_store,
potential_contacts: Arc::from([]), potential_contacts: Arc::from([]),
selected_index: 0, selected_index: 0,

View file

@ -110,7 +110,7 @@ impl NotificationPanel {
}) })
.detach(); .detach();
let model = cx.model().downgrade(); let model = cx.entity().downgrade();
let notification_list = let notification_list =
ListState::new(0, ListAlignment::Top, px(1000.), move |ix, window, cx| { ListState::new(0, ListAlignment::Top, px(1000.), move |ix, window, cx| {
model model
@ -323,7 +323,7 @@ impl NotificationPanel {
.justify_end() .justify_end()
.child(Button::new("decline", "Decline").on_click({ .child(Button::new("decline", "Decline").on_click({
let notification = notification.clone(); let notification = notification.clone();
let model = cx.model().clone(); let model = cx.entity().clone();
move |_, _, cx| { move |_, _, cx| {
model.update(cx, |this, cx| { model.update(cx, |this, cx| {
this.respond_to_notification( this.respond_to_notification(
@ -336,7 +336,7 @@ impl NotificationPanel {
})) }))
.child(Button::new("accept", "Accept").on_click({ .child(Button::new("accept", "Accept").on_click({
let notification = notification.clone(); let notification = notification.clone();
let model = cx.model().clone(); let model = cx.entity().clone();
move |_, _, cx| { move |_, _, cx| {
model.update(cx, |this, cx| { model.update(cx, |this, cx| {
this.respond_to_notification( this.respond_to_notification(
@ -570,7 +570,7 @@ impl NotificationPanel {
workspace.dismiss_notification(&id, cx); workspace.dismiss_notification(&id, cx);
workspace.show_notification(id, cx, |cx| { workspace.show_notification(id, cx, |cx| {
let workspace = cx.model().downgrade(); let workspace = cx.entity().downgrade();
cx.new(|_| NotificationToast { cx.new(|_| NotificationToast {
notification_id, notification_id,
actor, actor,

View file

@ -107,7 +107,7 @@ impl CommandPalette {
.collect(); .collect();
let delegate = let delegate =
CommandPaletteDelegate::new(cx.model().downgrade(), commands, previous_focus_handle); CommandPaletteDelegate::new(cx.entity().downgrade(), commands, previous_focus_handle);
let picker = cx.new(|cx| { let picker = cx.new(|cx| {
let picker = Picker::uniform_list(delegate, window, cx); let picker = Picker::uniform_list(delegate, window, cx);

View file

@ -283,7 +283,7 @@ impl ProjectDiagnosticsEditor {
if let Some(existing) = workspace.item_of_type::<ProjectDiagnosticsEditor>(cx) { if let Some(existing) = workspace.item_of_type::<ProjectDiagnosticsEditor>(cx) {
workspace.activate_item(&existing, true, true, window, cx); workspace.activate_item(&existing, true, true, window, cx);
} else { } else {
let workspace_handle = cx.model().downgrade(); let workspace_handle = cx.entity().downgrade();
let include_warnings = match cx.try_global::<IncludeWarnings>() { let include_warnings = match cx.try_global::<IncludeWarnings>() {
Some(include_warnings) => include_warnings.0, Some(include_warnings) => include_warnings.0,

View file

@ -495,7 +495,7 @@ impl CompletionsMenu {
let last_rendered_range = self.last_rendered_range.clone(); let last_rendered_range = self.last_rendered_range.clone();
let style = style.clone(); let style = style.clone();
let list = uniform_list( let list = uniform_list(
cx.model().clone(), cx.entity().clone(),
"completions", "completions",
self.entries.borrow().len(), self.entries.borrow().len(),
move |_editor, range, _window, cx| { move |_editor, range, _window, cx| {
@ -1090,7 +1090,7 @@ impl CodeActionsMenu {
let actions = self.actions.clone(); let actions = self.actions.clone();
let selected_item = self.selected_item; let selected_item = self.selected_item;
let list = uniform_list( let list = uniform_list(
cx.model().clone(), cx.entity().clone(),
"code_actions_menu", "code_actions_menu",
self.actions.len(), self.actions.len(),
move |_this, range, _, cx| { move |_this, range, _, cx| {

View file

@ -1159,7 +1159,7 @@ impl Editor {
) -> Self { ) -> Self {
let style = window.text_style(); let style = window.text_style();
let font_size = style.font_size.to_pixels(window.rem_size()); let font_size = style.font_size.to_pixels(window.rem_size());
let editor = cx.model().downgrade(); let editor = cx.entity().downgrade();
let fold_placeholder = FoldPlaceholder { let fold_placeholder = FoldPlaceholder {
constrain_width: true, constrain_width: true,
render: Arc::new(move |fold_id, fold_range, _, cx| { render: Arc::new(move |fold_id, fold_range, _, cx| {
@ -15339,7 +15339,7 @@ impl Render for Editor {
}; };
EditorElement::new( EditorElement::new(
&cx.model(), &cx.entity(),
EditorStyle { EditorStyle {
background, background,
local_player: cx.theme().players().local(), local_player: cx.theme().players().local(),

View file

@ -62,7 +62,7 @@ fn test_edit_events(cx: &mut TestAppContext) {
let editor1 = cx.add_window({ let editor1 = cx.add_window({
let events = events.clone(); let events = events.clone();
|window, cx| { |window, cx| {
let model = cx.model().clone(); let model = cx.entity().clone();
cx.subscribe_in( cx.subscribe_in(
&model, &model,
window, window,
@ -83,7 +83,7 @@ fn test_edit_events(cx: &mut TestAppContext) {
let events = events.clone(); let events = events.clone();
|window, cx| { |window, cx| {
cx.subscribe_in( cx.subscribe_in(
&cx.model().clone(), &cx.entity().clone(),
window, window,
move |_, _, event: &EditorEvent, _, _| match event { move |_, _, event: &EditorEvent, _, _| match event {
EditorEvent::Edited { .. } => events.borrow_mut().push(("editor2", "edited")), EditorEvent::Edited { .. } => events.borrow_mut().push(("editor2", "edited")),
@ -689,7 +689,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
cx.new(|cx| { cx.new(|cx| {
let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx); let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx);
let mut editor = build_editor(buffer.clone(), window, cx); let mut editor = build_editor(buffer.clone(), window, cx);
let handle = cx.model(); let handle = cx.entity();
editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(&handle))); editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(&handle)));
fn pop_history(editor: &mut Editor, cx: &mut App) -> Option<NavigationEntry> { fn pop_history(editor: &mut Editor, cx: &mut App) -> Option<NavigationEntry> {
@ -10180,8 +10180,8 @@ async fn test_following(cx: &mut gpui::TestAppContext) {
let is_still_following = Rc::new(RefCell::new(true)); let is_still_following = Rc::new(RefCell::new(true));
let follower_edit_event_count = Rc::new(RefCell::new(0)); let follower_edit_event_count = Rc::new(RefCell::new(0));
let pending_update = Rc::new(RefCell::new(None)); let pending_update = Rc::new(RefCell::new(None));
let leader_model = leader.root_model(cx).unwrap(); let leader_model = leader.root(cx).unwrap();
let follower_model = follower.root_model(cx).unwrap(); let follower_model = follower.root(cx).unwrap();
_ = follower.update(cx, { _ = follower.update(cx, {
let update = pending_update.clone(); let update = pending_update.clone();
let is_still_following = is_still_following.clone(); let is_still_following = is_still_following.clone();
@ -10368,7 +10368,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
// Start following the editor when it has no excerpts. // Start following the editor when it has no excerpts.
let mut state_message = let mut state_message =
leader.update_in(cx, |leader, window, cx| leader.to_state_proto(window, cx)); leader.update_in(cx, |leader, window, cx| leader.to_state_proto(window, cx));
let workspace_model = workspace.root_model(cx).unwrap(); let workspace_model = workspace.root(cx).unwrap();
let follower_1 = cx let follower_1 = cx
.update_window(*workspace.deref(), |_, window, cx| { .update_window(*workspace.deref(), |_, window, cx| {
Editor::from_state_proto( Editor::from_state_proto(
@ -10470,7 +10470,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
// Start following separately after it already has excerpts. // Start following separately after it already has excerpts.
let mut state_message = let mut state_message =
leader.update_in(cx, |leader, window, cx| leader.to_state_proto(window, cx)); leader.update_in(cx, |leader, window, cx| leader.to_state_proto(window, cx));
let workspace_model = workspace.root_model(cx).unwrap(); let workspace_model = workspace.root(cx).unwrap();
let follower_2 = cx let follower_2 = cx
.update_window(*workspace.deref(), |_, window, cx| { .update_window(*workspace.deref(), |_, window, cx| {
Editor::from_state_proto( Editor::from_state_proto(
@ -14497,7 +14497,7 @@ fn test_crease_insertion_and_rendering(cx: &mut TestAppContext) {
let _div = snapshot.render_crease_toggle( let _div = snapshot.render_crease_toggle(
MultiBufferRow(1), MultiBufferRow(1),
false, false,
cx.model().clone(), cx.entity().clone(),
window, window,
cx, cx,
); );
@ -14718,7 +14718,7 @@ async fn test_goto_definition_with_find_all_references_fallback(cx: &mut gpui::T
"Initially, only one, test, editor should be open in the workspace" "Initially, only one, test, editor should be open in the workspace"
); );
assert_eq!( assert_eq!(
test_editor_cx.model(), test_editor_cx.entity(),
editors.last().expect("Asserted len is 1").clone() editors.last().expect("Asserted len is 1").clone()
); );
}); });
@ -14754,7 +14754,7 @@ async fn test_goto_definition_with_find_all_references_fallback(cx: &mut gpui::T
); );
let references_fallback_text = editors let references_fallback_text = editors
.into_iter() .into_iter()
.find(|new_editor| *new_editor != test_editor_cx.model()) .find(|new_editor| *new_editor != test_editor_cx.entity())
.expect("Should have one non-test editor now") .expect("Should have one non-test editor now")
.read(test_editor_cx) .read(test_editor_cx)
.text(test_editor_cx); .text(test_editor_cx);

View file

@ -6246,7 +6246,7 @@ impl Element for EditorElement {
let height = self.style.text.line_height_in_pixels(rem_size); let height = self.style.text.line_height_in_pixels(rem_size);
if auto_width { if auto_width {
let editor_handle = cx.model().clone(); let editor_handle = cx.entity().clone();
let style = self.style.clone(); let style = self.style.clone();
window.request_measured_layout( window.request_measured_layout(
Style::default(), Style::default(),
@ -6287,7 +6287,7 @@ impl Element for EditorElement {
} }
} }
EditorMode::AutoHeight { max_lines } => { EditorMode::AutoHeight { max_lines } => {
let editor_handle = cx.model().clone(); let editor_handle = cx.entity().clone();
let max_line_number_width = let max_line_number_width =
self.max_line_number_width(&editor.snapshot(window, cx), window, cx); self.max_line_number_width(&editor.snapshot(window, cx), window, cx);
window.request_measured_layout( window.request_measured_layout(

View file

@ -77,7 +77,7 @@ impl ProjectDiffEditor {
if let Some(existing) = workspace.item_of_type::<Self>(cx) { if let Some(existing) = workspace.item_of_type::<Self>(cx) {
workspace.activate_item(&existing, true, true, window, cx); workspace.activate_item(&existing, true, true, window, cx);
} else { } else {
let workspace_handle = cx.model().downgrade(); let workspace_handle = cx.entity().downgrade();
let project_diff = let project_diff =
cx.new(|cx| Self::new(workspace.project().clone(), workspace_handle, window, cx)); cx.new(|cx| Self::new(workspace.project().clone(), workspace_handle, window, cx));
workspace.add_item_to_active_pane(Box::new(project_diff), None, true, window, cx); workspace.add_item_to_active_pane(Box::new(project_diff), None, true, window, cx);

View file

@ -596,7 +596,7 @@ impl Editor {
style: BlockStyle::Sticky, style: BlockStyle::Sticky,
priority: 0, priority: 0,
render: Arc::new({ render: Arc::new({
let editor = cx.model().clone(); let editor = cx.entity().clone();
let hunk = hunk.clone(); let hunk = hunk.clone();
let has_multiple_hunks = self.has_multiple_hunks(cx); let has_multiple_hunks = self.has_multiple_hunks(cx);
@ -870,7 +870,7 @@ impl Editor {
let deleted_hunk_color = deleted_hunk_color(cx); let deleted_hunk_color = deleted_hunk_color(cx);
let (editor_height, editor_with_deleted_text) = let (editor_height, editor_with_deleted_text) =
editor_with_deleted_text(diff_base_buffer, deleted_hunk_color, hunk, window, cx); editor_with_deleted_text(diff_base_buffer, deleted_hunk_color, hunk, window, cx);
let editor = cx.model().clone(); let editor = cx.entity().clone();
let hunk = hunk.clone(); let hunk = hunk.clone();
let height = editor_height.max(deleted_text_height); let height = editor_height.max(deleted_text_height);
BlockProperties { BlockProperties {
@ -1214,7 +1214,7 @@ fn editor_with_deleted_text(
window: &mut Window, window: &mut Window,
cx: &mut Context<Editor>, cx: &mut Context<Editor>,
) -> (u32, Model<Editor>) { ) -> (u32, Model<Editor>) {
let parent_editor = cx.model().downgrade(); let parent_editor = cx.entity().downgrade();
let editor = cx.new(|cx| { let editor = cx.new(|cx| {
let multi_buffer = cx.new(|_| MultiBuffer::without_headers(language::Capability::ReadOnly)); let multi_buffer = cx.new(|_| MultiBuffer::without_headers(language::Capability::ReadOnly));
multi_buffer.update(cx, |multi_buffer, cx| { multi_buffer.update(cx, |multi_buffer, cx| {

View file

@ -317,7 +317,7 @@ impl ScrollManager {
self.show_scrollbar(window, cx); self.show_scrollbar(window, cx);
self.autoscroll_request.take(); self.autoscroll_request.take();
if let Some(workspace_id) = workspace_id { if let Some(workspace_id) = workspace_id {
let item_id = cx.model().entity_id().as_u64() as ItemId; let item_id = cx.entity().entity_id().as_u64() as ItemId;
cx.foreground_executor() cx.foreground_executor()
.spawn(async move { .spawn(async move {

View file

@ -133,7 +133,7 @@ impl EditorLspTestContext {
let window = cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx)); let window = cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx));
let workspace = window.root_model(cx).unwrap(); let workspace = window.root(cx).unwrap();
let mut cx = VisualTestContext::from_window(*window.deref(), cx); let mut cx = VisualTestContext::from_window(*window.deref(), cx);
project project

View file

@ -67,7 +67,7 @@ impl EditorTestContext {
window.focus(&editor.focus_handle(cx)); window.focus(&editor.focus_handle(cx));
editor editor
}); });
let editor_view = editor.root_model(cx).unwrap(); let editor_view = editor.root(cx).unwrap();
cx.run_until_parked(); cx.run_until_parked();
Self { Self {
@ -89,7 +89,7 @@ impl EditorTestContext {
} }
pub async fn for_editor(editor: WindowHandle<Editor>, cx: &mut gpui::TestAppContext) -> Self { pub async fn for_editor(editor: WindowHandle<Editor>, cx: &mut gpui::TestAppContext) -> Self {
let editor_view = editor.root_model(cx).unwrap(); let editor_view = editor.root(cx).unwrap();
Self { Self {
cx: VisualTestContext::from_window(*editor.deref(), cx), cx: VisualTestContext::from_window(*editor.deref(), cx),
window: editor.into(), window: editor.into(),
@ -126,7 +126,7 @@ impl EditorTestContext {
editor editor
}); });
let editor_view = editor.root_model(cx).unwrap(); let editor_view = editor.root(cx).unwrap();
Self { Self {
cx: VisualTestContext::from_window(*editor.deref(), cx), cx: VisualTestContext::from_window(*editor.deref(), cx),
window: editor.into(), window: editor.into(),

View file

@ -74,7 +74,7 @@ pub fn init(cx: &mut App) {
cx, cx,
); );
let workspace_handle = cx.model().downgrade(); let workspace_handle = cx.entity().downgrade();
window window
.spawn(cx, |mut cx| async move { .spawn(cx, |mut cx| async move {
let extension_path = let extension_path =
@ -533,7 +533,7 @@ impl ExtensionsPage {
extension: &ExtensionMetadata, extension: &ExtensionMetadata,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> ExtensionCard { ) -> ExtensionCard {
let this = cx.model().clone(); let this = cx.entity().clone();
let status = Self::extension_status(&extension.id, cx); let status = Self::extension_status(&extension.id, cx);
let has_dev_extension = Self::dev_extension_exists(&extension.id, cx); let has_dev_extension = Self::dev_extension_exists(&extension.id, cx);
@ -715,7 +715,7 @@ impl ExtensionsPage {
workspace.toggle_modal(window, cx, |window, cx| { workspace.toggle_modal(window, cx, |window, cx| {
let delegate = ExtensionVersionSelectorDelegate::new( let delegate = ExtensionVersionSelectorDelegate::new(
fs, fs,
cx.model().downgrade(), cx.entity().downgrade(),
extension_versions, extension_versions,
); );
@ -1160,7 +1160,7 @@ impl Render for ExtensionsPage {
return this.py_4().child(self.render_empty_state(cx)); return this.py_4().child(self.render_empty_state(cx));
} }
let extensions_page = cx.model().clone(); let extensions_page = cx.entity().clone();
let scroll_handle = self.list.clone(); let scroll_handle = self.list.clone();
this.child( this.child(
uniform_list(extensions_page, "entries", count, Self::render_extensions) uniform_list(extensions_page, "entries", count, Self::render_extensions)

View file

@ -132,7 +132,7 @@ impl ModalView for FeedbackModal {
impl FeedbackModal { impl FeedbackModal {
pub fn register(workspace: &mut Workspace, _: &mut Window, cx: &mut Context<Workspace>) { pub fn register(workspace: &mut Workspace, _: &mut Window, cx: &mut Context<Workspace>) {
let _handle = cx.model().downgrade(); let _handle = cx.entity().downgrade();
workspace.register_action(move |workspace, _: &GiveFeedback, window, cx| { workspace.register_action(move |workspace, _: &GiveFeedback, window, cx| {
workspace workspace
.with_local_workspace(window, cx, |workspace, window, cx| { .with_local_workspace(window, cx, |workspace, window, cx| {

View file

@ -147,10 +147,10 @@ impl FileFinder {
workspace workspace
.update_in(&mut cx, |workspace, window, cx| { .update_in(&mut cx, |workspace, window, cx| {
let project = workspace.project().clone(); let project = workspace.project().clone();
let weak_workspace = cx.model().downgrade(); let weak_workspace = cx.entity().downgrade();
workspace.toggle_modal(window, cx, |window, cx| { workspace.toggle_modal(window, cx, |window, cx| {
let delegate = FileFinderDelegate::new( let delegate = FileFinderDelegate::new(
cx.model().downgrade(), cx.entity().downgrade(),
weak_workspace, weak_workspace,
project, project,
currently_opened_path, currently_opened_path,

View file

@ -156,7 +156,7 @@ impl GitPanel {
let git_state = project.read(cx).git_state().cloned(); let git_state = project.read(cx).git_state().cloned();
let active_repository = project.read(cx).active_repository(cx); let active_repository = project.read(cx).active_repository(cx);
let (err_sender, mut err_receiver) = mpsc::channel(1); let (err_sender, mut err_receiver) = mpsc::channel(1);
let workspace = cx.model().downgrade(); let workspace = cx.entity().downgrade();
let git_panel = cx.new(|cx| { let git_panel = cx.new(|cx| {
let focus_handle = cx.focus_handle(); let focus_handle = cx.focus_handle();
@ -193,7 +193,7 @@ impl GitPanel {
current_modifiers: window.modifiers(), current_modifiers: window.modifiers(),
width: Some(px(360.)), width: Some(px(360.)),
scrollbar_state: ScrollbarState::new(scroll_handle.clone()) scrollbar_state: ScrollbarState::new(scroll_handle.clone())
.parent_model(&cx.model()), .parent_model(&cx.entity()),
selected_entry: None, selected_entry: None,
show_scrollbar: false, show_scrollbar: false,
hide_scrollbar_task: None, hide_scrollbar_task: None,
@ -703,7 +703,7 @@ impl GitPanel {
} }
fn schedule_update(&mut self, window: &mut Window, cx: &mut Context<Self>) { fn schedule_update(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
self.update_visible_entries_task = cx.spawn_in(window, |_, mut cx| async move { self.update_visible_entries_task = cx.spawn_in(window, |_, mut cx| async move {
cx.background_executor().timer(UPDATE_DEBOUNCE).await; cx.background_executor().timer(UPDATE_DEBOUNCE).await;
if let Some(this) = handle.upgrade() { if let Some(this) = handle.upgrade() {
@ -1114,7 +1114,7 @@ impl GitPanel {
.size_full() .size_full()
.overflow_hidden() .overflow_hidden()
.child( .child(
uniform_list(cx.model().clone(), "entries", entry_count, { uniform_list(cx.entity().clone(), "entries", entry_count, {
move |git_panel, range, _window, cx| { move |git_panel, range, _window, cx| {
let mut items = Vec::with_capacity(range.end - range.start); let mut items = Vec::with_capacity(range.end - range.start);
git_panel.for_each_visible_entry(range, cx, |ix, details, cx| { git_panel.for_each_visible_entry(range, cx, |ix, details, cx| {
@ -1167,7 +1167,7 @@ impl GitPanel {
let checkbox_id = let checkbox_id =
ElementId::Name(format!("checkbox_{}", entry_details.display_name).into()); ElementId::Name(format!("checkbox_{}", entry_details.display_name).into());
let is_tree_view = false; let is_tree_view = false;
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
let end_slot = h_flex() let end_slot = h_flex()
.invisible() .invisible()

View file

@ -27,7 +27,7 @@ impl RepositorySelector {
let filtered_repositories = all_repositories.clone(); let filtered_repositories = all_repositories.clone();
let delegate = RepositorySelectorDelegate { let delegate = RepositorySelectorDelegate {
project: project.downgrade(), project: project.downgrade(),
repository_selector: cx.model().downgrade(), repository_selector: cx.entity().downgrade(),
repository_entries: all_repositories, repository_entries: all_repositories,
filtered_repositories, filtered_repositories,
selected_index: 0, selected_index: 0,

View file

@ -42,7 +42,7 @@ enum GoToLineRowHighlights {}
impl GoToLine { impl GoToLine {
fn register(editor: &mut Editor, _window: Option<&mut Window>, cx: &mut Context<Editor>) { fn register(editor: &mut Editor, _window: Option<&mut Window>, cx: &mut Context<Editor>) {
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
editor editor
.register_action(move |_: &editor::actions::ToggleGoToLine, window, cx| { .register_action(move |_: &editor::actions::ToggleGoToLine, window, cx| {
let Some(editor_handle) = handle.upgrade() else { let Some(editor_handle) = handle.upgrade() else {
@ -94,7 +94,7 @@ impl GoToLine {
let line_editor = cx.new(|cx| { let line_editor = cx.new(|cx| {
let mut editor = Editor::single_line(window, cx); let mut editor = Editor::single_line(window, cx);
let editor_handle = cx.model().downgrade(); let editor_handle = cx.entity().downgrade();
editor editor
.register_action::<Tab>({ .register_action::<Tab>({
move |_, window, cx| { move |_, window, cx| {

View file

@ -572,7 +572,7 @@ impl Render for TextInput {
.p(px(4.)) .p(px(4.))
.bg(white()) .bg(white())
.child(TextElement { .child(TextElement {
input: cx.model().clone(), input: cx.entity().clone(),
}), }),
) )
} }
@ -697,7 +697,7 @@ fn main() {
}, },
) )
.unwrap(); .unwrap();
let view = window.root_model(cx).unwrap(); let view = window.root(cx).unwrap();
cx.observe_keystrokes(move |ev, _, cx| { cx.observe_keystrokes(move |ev, _, cx| {
view.update(cx, |view, cx| { view.update(cx, |view, cx| {
view.recent_keystrokes.push(ev.keystroke.clone()); view.recent_keystrokes.push(ev.keystroke.clone());

View file

@ -9,7 +9,7 @@ impl Render for UniformListExample {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
div().size_full().bg(rgb(0xffffff)).child( div().size_full().bg(rgb(0xffffff)).child(
uniform_list( uniform_list(
cx.model().clone(), cx.entity().clone(),
"entries", "entries",
50, 50,
|_this, range, _window, _cx| { |_this, range, _window, _cx| {

View file

@ -603,7 +603,7 @@ impl App {
cx.window_update_stack.push(id); cx.window_update_stack.push(id);
let root_view = build_root_view(&mut window, cx); let root_view = build_root_view(&mut window, cx);
cx.window_update_stack.pop(); cx.window_update_stack.pop();
window.root_model.replace(root_view.into()); window.root.replace(root_view.into());
window.defer(cx, |window: &mut Window, cx| window.appearance_changed(cx)); window.defer(cx, |window: &mut Window, cx| window.appearance_changed(cx));
cx.window_handles.insert(id, window.handle); cx.window_handles.insert(id, window.handle);
cx.windows.get_mut(id).unwrap().replace(window); cx.windows.get_mut(id).unwrap().replace(window);
@ -999,7 +999,7 @@ impl App {
.take() .take()
.ok_or_else(|| anyhow!("window not found"))?; .ok_or_else(|| anyhow!("window not found"))?;
let root_view = window.root_model.clone().unwrap(); let root_view = window.root.clone().unwrap();
cx.window_update_stack.push(window.handle.id); cx.window_update_stack.push(window.handle.id);
let result = update(root_view, &mut window, cx); let result = update(root_view, &mut window, cx);
@ -1666,7 +1666,7 @@ impl AppContext for App {
.as_ref() .as_ref()
.expect("attempted to read a window that is already on the stack"); .expect("attempted to read a window that is already on the stack");
let root_view = window.root_model.clone().unwrap(); let root_view = window.root.clone().unwrap();
let view = root_view let view = root_view
.downcast::<T>() .downcast::<T>()
.map_err(|_| anyhow!("root view's type has changed"))?; .map_err(|_| anyhow!("root view's type has changed"))?;

View file

@ -399,9 +399,8 @@ impl VisualContext for AsyncWindowContext {
where where
V: 'static + Render, V: 'static + Render,
{ {
self.window.update(self, |_, window, cx| { self.window
window.replace_root_model(cx, build_view) .update(self, |_, window, cx| window.replace_root(cx, build_view))
})
} }
fn focus<V>(&mut self, view: &Entity<V>) -> Self::Result<()> fn focus<V>(&mut self, view: &Entity<V>) -> Self::Result<()>

View file

@ -35,14 +35,14 @@ impl<'a, T: 'static> Context<'a, T> {
} }
/// Returns a handle to the model belonging to this context. /// Returns a handle to the model belonging to this context.
pub fn model(&self) -> Entity<T> { pub fn entity(&self) -> Entity<T> {
self.weak_model() self.weak_entity()
.upgrade() .upgrade()
.expect("The entity must be alive if we have a model context") .expect("The entity must be alive if we have a model context")
} }
/// Returns a weak handle to the model belonging to this context. /// Returns a weak handle to the model belonging to this context.
pub fn weak_model(&self) -> WeakEntity<T> { pub fn weak_entity(&self) -> WeakEntity<T> {
self.model_state.clone() self.model_state.clone()
} }
@ -57,7 +57,7 @@ impl<'a, T: 'static> Context<'a, T> {
T: 'static, T: 'static,
W: 'static, W: 'static,
{ {
let this = self.weak_model(); let this = self.weak_entity();
self.app.observe_internal(entity, move |e, cx| { self.app.observe_internal(entity, move |e, cx| {
if let Some(this) = this.upgrade() { if let Some(this) = this.upgrade() {
this.update(cx, |this, cx| on_notify(this, e, cx)); this.update(cx, |this, cx| on_notify(this, e, cx));
@ -79,7 +79,7 @@ impl<'a, T: 'static> Context<'a, T> {
T2: 'static + EventEmitter<Evt>, T2: 'static + EventEmitter<Evt>,
Evt: 'static, Evt: 'static,
{ {
let this = self.weak_model(); let this = self.weak_entity();
self.app.subscribe_internal(entity, move |e, event, cx| { self.app.subscribe_internal(entity, move |e, event, cx| {
if let Some(this) = this.upgrade() { if let Some(this) = this.upgrade() {
this.update(cx, |this, cx| on_event(this, e, event, cx)); this.update(cx, |this, cx| on_event(this, e, event, cx));
@ -117,7 +117,7 @@ impl<'a, T: 'static> Context<'a, T> {
T2: 'static, T2: 'static,
{ {
let entity_id = entity.entity_id(); let entity_id = entity.entity_id();
let this = self.weak_model(); let this = self.weak_entity();
let (subscription, activate) = self.app.release_listeners.insert( let (subscription, activate) = self.app.release_listeners.insert(
entity_id, entity_id,
Box::new(move |entity, cx| { Box::new(move |entity, cx| {
@ -139,7 +139,7 @@ impl<'a, T: 'static> Context<'a, T> {
where where
T: 'static, T: 'static,
{ {
let handle = self.weak_model(); let handle = self.weak_entity();
let (subscription, activate) = self.global_observers.insert( let (subscription, activate) = self.global_observers.insert(
TypeId::of::<G>(), TypeId::of::<G>(),
Box::new(move |cx| handle.update(cx, |view, cx| f(view, cx)).is_ok()), Box::new(move |cx| handle.update(cx, |view, cx| f(view, cx)).is_ok()),
@ -158,7 +158,7 @@ impl<'a, T: 'static> Context<'a, T> {
Fut: 'static + Future<Output = ()>, Fut: 'static + Future<Output = ()>,
T: 'static, T: 'static,
{ {
let handle = self.weak_model(); let handle = self.weak_entity();
let (subscription, activate) = self.app.quit_observers.insert( let (subscription, activate) = self.app.quit_observers.insert(
(), (),
Box::new(move |cx| { Box::new(move |cx| {
@ -189,7 +189,7 @@ impl<'a, T: 'static> Context<'a, T> {
Fut: Future<Output = R> + 'static, Fut: Future<Output = R> + 'static,
R: 'static, R: 'static,
{ {
let this = self.weak_model(); let this = self.weak_entity();
self.app.spawn(|cx| f(this, cx)) self.app.spawn(|cx| f(this, cx))
} }
@ -202,7 +202,7 @@ impl<'a, T: 'static> Context<'a, T> {
&self, &self,
f: impl Fn(&mut T, &E, &mut Window, &mut Context<T>) + 'static, f: impl Fn(&mut T, &E, &mut Window, &mut Context<T>) + 'static,
) -> impl Fn(&E, &mut Window, &mut App) + 'static { ) -> impl Fn(&E, &mut Window, &mut App) + 'static {
let view = self.model().downgrade(); let view = self.entity().downgrade();
move |e: &E, window: &mut Window, cx: &mut App| { move |e: &E, window: &mut Window, cx: &mut App| {
view.update(cx, |view, cx| f(view, e, window, cx)).ok(); view.update(cx, |view, cx| f(view, e, window, cx)).ok();
} }
@ -221,7 +221,7 @@ impl<'a, T: 'static> Context<'a, T> {
) where ) where
T: 'static, T: 'static,
{ {
let view = self.model(); let view = self.entity();
window.on_next_frame(move |window, cx| view.update(cx, |view, cx| f(view, window, cx))); window.on_next_frame(move |window, cx| view.update(cx, |view, cx| f(view, window, cx)));
} }
@ -232,7 +232,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &Window, window: &Window,
f: impl FnOnce(&mut T, &mut Window, &mut Context<T>) + 'static, f: impl FnOnce(&mut T, &mut Window, &mut Context<T>) + 'static,
) { ) {
let view = self.model(); let view = self.entity();
window.defer(self, move |window, cx| { window.defer(self, move |window, cx| {
view.update(cx, |view, cx| f(view, window, cx)) view.update(cx, |view, cx| f(view, window, cx))
}); });
@ -252,7 +252,7 @@ impl<'a, T: 'static> Context<'a, T> {
let observed_id = observed.entity_id(); let observed_id = observed.entity_id();
let observed = observed.downgrade(); let observed = observed.downgrade();
let window_handle = window.handle; let window_handle = window.handle;
let observer = self.weak_model(); let observer = self.weak_entity();
self.new_observer( self.new_observer(
observed_id, observed_id,
Box::new(move |cx| { Box::new(move |cx| {
@ -290,7 +290,7 @@ impl<'a, T: 'static> Context<'a, T> {
{ {
let emitter = emitter.downgrade(); let emitter = emitter.downgrade();
let window_handle = window.handle; let window_handle = window.handle;
let subscriber = self.weak_model(); let subscriber = self.weak_entity();
self.new_subscription( self.new_subscription(
emitter.entity_id(), emitter.entity_id(),
( (
@ -348,7 +348,7 @@ impl<'a, T: 'static> Context<'a, T> {
T: 'static, T: 'static,
V2: 'static, V2: 'static,
{ {
let observer = self.weak_model(); let observer = self.weak_entity();
let window_handle = window.handle; let window_handle = window.handle;
let (subscription, activate) = self.release_listeners.insert( let (subscription, activate) = self.release_listeners.insert(
observed.entity_id(), observed.entity_id(),
@ -371,7 +371,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut callback: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static, mut callback: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let (subscription, activate) = window.bounds_observers.insert( let (subscription, activate) = window.bounds_observers.insert(
(), (),
Box::new(move |window, cx| { Box::new(move |window, cx| {
@ -389,7 +389,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut callback: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static, mut callback: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let (subscription, activate) = window.activation_observers.insert( let (subscription, activate) = window.activation_observers.insert(
(), (),
Box::new(move |window, cx| { Box::new(move |window, cx| {
@ -407,7 +407,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut callback: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static, mut callback: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let (subscription, activate) = window.appearance_observers.insert( let (subscription, activate) = window.appearance_observers.insert(
(), (),
Box::new(move |window, cx| { Box::new(move |window, cx| {
@ -435,7 +435,7 @@ impl<'a, T: 'static> Context<'a, T> {
subscription subscription
} }
let view = self.weak_model(); let view = self.weak_entity();
inner( inner(
&mut self.keystroke_observers, &mut self.keystroke_observers,
Box::new(move |event, window, cx| { Box::new(move |event, window, cx| {
@ -455,7 +455,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut callback: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static, mut callback: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let (subscription, activate) = window.pending_input_observers.insert( let (subscription, activate) = window.pending_input_observers.insert(
(), (),
Box::new(move |window, cx| { Box::new(move |window, cx| {
@ -475,7 +475,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut listener: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static, mut listener: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let focus_id = handle.id; let focus_id = handle.id;
let (subscription, activate) = let (subscription, activate) =
window.new_focus_listener(Box::new(move |event, window, cx| { window.new_focus_listener(Box::new(move |event, window, cx| {
@ -501,7 +501,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut listener: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static, mut listener: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let focus_id = handle.id; let focus_id = handle.id;
let (subscription, activate) = let (subscription, activate) =
window.new_focus_listener(Box::new(move |event, window, cx| { window.new_focus_listener(Box::new(move |event, window, cx| {
@ -524,7 +524,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut listener: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static, mut listener: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let focus_id = handle.id; let focus_id = handle.id;
let (subscription, activate) = let (subscription, activate) =
window.new_focus_listener(Box::new(move |event, window, cx| { window.new_focus_listener(Box::new(move |event, window, cx| {
@ -550,7 +550,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut listener: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static, mut listener: impl FnMut(&mut T, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let (subscription, activate) = window.focus_lost_listeners.insert( let (subscription, activate) = window.focus_lost_listeners.insert(
(), (),
Box::new(move |window, cx| { Box::new(move |window, cx| {
@ -570,7 +570,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
mut listener: impl FnMut(&mut T, FocusOutEvent, &mut Window, &mut Context<T>) + 'static, mut listener: impl FnMut(&mut T, FocusOutEvent, &mut Window, &mut Context<T>) + 'static,
) -> Subscription { ) -> Subscription {
let view = self.weak_model(); let view = self.weak_entity();
let focus_id = handle.id; let focus_id = handle.id;
let (subscription, activate) = let (subscription, activate) =
window.new_focus_listener(Box::new(move |event, window, cx| { window.new_focus_listener(Box::new(move |event, window, cx| {
@ -606,7 +606,7 @@ impl<'a, T: 'static> Context<'a, T> {
R: 'static, R: 'static,
Fut: Future<Output = R> + 'static, Fut: Future<Output = R> + 'static,
{ {
let view = self.weak_model(); let view = self.weak_entity();
window.spawn(self, |mut cx| f(view, cx)) window.spawn(self, |mut cx| f(view, cx))
} }
@ -617,7 +617,7 @@ impl<'a, T: 'static> Context<'a, T> {
mut f: impl FnMut(&mut T, &mut Window, &mut Context<'_, T>) + 'static, mut f: impl FnMut(&mut T, &mut Window, &mut Context<'_, T>) + 'static,
) -> Subscription { ) -> Subscription {
let window_handle = window.handle; let window_handle = window.handle;
let view = self.weak_model(); let view = self.weak_entity();
let (subscription, activate) = self.global_observers.insert( let (subscription, activate) = self.global_observers.insert(
TypeId::of::<G>(), TypeId::of::<G>(),
Box::new(move |cx| { Box::new(move |cx| {
@ -639,7 +639,7 @@ impl<'a, T: 'static> Context<'a, T> {
window: &mut Window, window: &mut Window,
listener: impl Fn(&mut T, &dyn Any, DispatchPhase, &mut Window, &mut Context<T>) + 'static, listener: impl Fn(&mut T, &dyn Any, DispatchPhase, &mut Window, &mut Context<T>) + 'static,
) { ) {
let handle = self.weak_model(); let handle = self.weak_entity();
window.on_action(action_type, move |action, phase, window, cx| { window.on_action(action_type, move |action, phase, window, cx| {
handle handle
.update(cx, |view, cx| { .update(cx, |view, cx| {
@ -654,7 +654,7 @@ impl<'a, T: 'static> Context<'a, T> {
where where
T: Focusable, T: Focusable,
{ {
let view = self.model(); let view = self.entity();
window.defer(self, move |window, cx| { window.defer(self, move |window, cx| {
view.read(cx).focus_handle(cx).focus(window) view.read(cx).focus_handle(cx).focus(window)
}) })

View file

@ -238,7 +238,7 @@ impl TestAppContext {
) )
.unwrap(); .unwrap();
drop(cx); drop(cx);
let view = window.root_model(self).unwrap(); let view = window.root(self).unwrap();
let cx = VisualTestContext::from_window(*window.deref(), self).as_mut(); let cx = VisualTestContext::from_window(*window.deref(), self).as_mut();
cx.run_until_parked(); cx.run_until_parked();
@ -946,7 +946,7 @@ impl VisualContext for VisualTestContext {
{ {
self.window self.window
.update(&mut self.cx, |_, window, cx| { .update(&mut self.cx, |_, window, cx| {
window.replace_root_model(cx, build_view) window.replace_root(cx, build_view)
}) })
.unwrap() .unwrap()
} }

View file

@ -609,7 +609,7 @@ pub struct Window {
rem_size_override_stack: SmallVec<[Pixels; 8]>, rem_size_override_stack: SmallVec<[Pixels; 8]>,
pub(crate) viewport_size: Size<Pixels>, pub(crate) viewport_size: Size<Pixels>,
layout_engine: Option<TaffyLayoutEngine>, layout_engine: Option<TaffyLayoutEngine>,
pub(crate) root_model: Option<AnyView>, pub(crate) root: Option<AnyView>,
pub(crate) element_id_stack: SmallVec<[ElementId; 32]>, pub(crate) element_id_stack: SmallVec<[ElementId; 32]>,
pub(crate) text_style_stack: Vec<TextStyleRefinement>, pub(crate) text_style_stack: Vec<TextStyleRefinement>,
pub(crate) element_offset_stack: Vec<Point<Pixels>>, pub(crate) element_offset_stack: Vec<Point<Pixels>>,
@ -887,7 +887,7 @@ impl Window {
rem_size_override_stack: SmallVec::new(), rem_size_override_stack: SmallVec::new(),
viewport_size: content_size, viewport_size: content_size,
layout_engine: Some(TaffyLayoutEngine::new()), layout_engine: Some(TaffyLayoutEngine::new()),
root_model: None, root: None,
element_id_stack: SmallVec::default(), element_id_stack: SmallVec::default(),
text_style_stack: Vec::new(), text_style_stack: Vec::new(),
element_offset_stack: Vec::new(), element_offset_stack: Vec::new(),
@ -1019,27 +1019,27 @@ impl Window {
subscription subscription
} }
pub fn replace_root_model<V>( pub fn replace_root<E>(
&mut self, &mut self,
cx: &mut App, cx: &mut App,
build_view: impl FnOnce(&mut Window, &mut Context<'_, V>) -> V, build_view: impl FnOnce(&mut Window, &mut Context<'_, E>) -> E,
) -> Entity<V> ) -> Entity<E>
where where
V: 'static + Render, E: 'static + Render,
{ {
let view = cx.new(|cx| build_view(self, cx)); let view = cx.new(|cx| build_view(self, cx));
self.root_model = Some(view.clone().into()); self.root = Some(view.clone().into());
self.refresh(); self.refresh();
view view
} }
pub fn root_model<V>(&mut self) -> Option<Option<Entity<V>>> pub fn root<E>(&self) -> Option<Option<Entity<E>>>
where where
V: 'static + Render, E: 'static + Render,
{ {
self.root_model self.root
.as_ref() .as_ref()
.map(|view| view.clone().downcast::<V>().ok()) .map(|view| view.clone().downcast::<E>().ok())
} }
/// Obtain a handle to the window that belongs to this context. /// Obtain a handle to the window that belongs to this context.
@ -1632,7 +1632,7 @@ impl Window {
self.tooltip_bounds.take(); self.tooltip_bounds.take();
// Layout all root elements. // Layout all root elements.
let mut root_element = self.root_model.as_ref().unwrap().clone().into_any(); let mut root_element = self.root.as_ref().unwrap().clone().into_any();
root_element.prepaint_as_root(Point::default(), self.viewport_size.into(), self, cx); root_element.prepaint_as_root(Point::default(), self.viewport_size.into(), self, cx);
let mut sorted_deferred_draws = let mut sorted_deferred_draws =
@ -3816,7 +3816,7 @@ impl<V: 'static + Render> WindowHandle<V> {
.and_then(|window| { .and_then(|window| {
window window
.as_ref() .as_ref()
.and_then(|window| window.root_model.clone()) .and_then(|window| window.root.clone())
.map(|root_view| root_view.downcast::<V>()) .map(|root_view| root_view.downcast::<V>())
}) })
.ok_or_else(|| anyhow!("window not found"))? .ok_or_else(|| anyhow!("window not found"))?
@ -3838,7 +3838,7 @@ impl<V: 'static + Render> WindowHandle<V> {
/// Read the root view pointer off of this window. /// Read the root view pointer off of this window.
/// ///
/// This will fail if the window is closed or if the root view's type does not match `V`. /// This will fail if the window is closed or if the root view's type does not match `V`.
pub fn root_model<C>(&self, cx: &C) -> Result<Entity<V>> pub fn entity<C>(&self, cx: &C) -> Result<Entity<V>>
where where
C: AppContext, C: AppContext,
{ {

View file

@ -121,7 +121,7 @@ impl Render for InlineCompletionButton {
}), }),
); );
} }
let this = cx.model().clone(); let this = cx.entity().clone();
div().child( div().child(
PopoverMenu::new("copilot") PopoverMenu::new("copilot")
@ -173,7 +173,7 @@ impl Render for InlineCompletionButton {
let icon = status.to_icon(); let icon = status.to_icon();
let tooltip_text = status.to_tooltip(); let tooltip_text = status.to_tooltip();
let has_menu = status.has_menu(); let has_menu = status.has_menu();
let this = cx.model().clone(); let this = cx.entity().clone();
let fs = self.fs.clone(); let fs = self.fs.clone();
return div().child( return div().child(
@ -268,7 +268,7 @@ impl Render for InlineCompletionButton {
); );
} }
let this = cx.model().clone(); let this = cx.entity().clone();
let button = IconButton::new("zeta", IconName::ZedPredict).when( let button = IconButton::new("zeta", IconName::ZedPredict).when(
!self.popover_menu_handle.is_deployed(), !self.popover_menu_handle.is_deployed(),
|button| { |button| {
@ -399,7 +399,7 @@ impl InlineCompletionButton {
None, None,
move |window, cx| { move |window, cx| {
if let Some(workspace) = window.window_handle().downcast::<Workspace>() { if let Some(workspace) = window.window_handle().downcast::<Workspace>() {
if let Ok(workspace) = workspace.root_model(cx) { if let Ok(workspace) = workspace.root(cx) {
let workspace = workspace.downgrade(); let workspace = workspace.downgrade();
window window
.spawn(cx, |cx| { .spawn(cx, |cx| {

View file

@ -972,7 +972,7 @@ impl Buffer {
} }
pub fn branch(&mut self, cx: &mut Context<Self>) -> Entity<Self> { pub fn branch(&mut self, cx: &mut Context<Self>) -> Entity<Self> {
let this = cx.model(); let this = cx.entity();
cx.new(|cx| { cx.new(|cx| {
let mut branch = Self { let mut branch = Self {
branch_state: Some(BufferBranchState { branch_state: Some(BufferBranchState {

View file

@ -2805,7 +2805,7 @@ fn test_random_collaboration(cx: &mut App, mut rng: StdRng) {
); );
buffer.set_group_interval(Duration::from_millis(rng.gen_range(0..=200))); buffer.set_group_interval(Duration::from_millis(rng.gen_range(0..=200)));
let network = network.clone(); let network = network.clone();
cx.subscribe(&cx.model(), move |buffer, _, event, _| { cx.subscribe(&cx.entity(), move |buffer, _, event, _| {
if let BufferEvent::Operation { if let BufferEvent::Operation {
operation, operation,
is_local: true, is_local: true,
@ -2936,7 +2936,7 @@ fn test_random_collaboration(cx: &mut App, mut rng: StdRng) {
); );
new_buffer.set_group_interval(Duration::from_millis(rng.gen_range(0..=200))); new_buffer.set_group_interval(Duration::from_millis(rng.gen_range(0..=200)));
let network = network.clone(); let network = network.clone();
cx.subscribe(&cx.model(), move |buffer, _, event, _| { cx.subscribe(&cx.entity(), move |buffer, _, event, _| {
if let BufferEvent::Operation { if let BufferEvent::Operation {
operation, operation,
is_local: true, is_local: true,

View file

@ -33,7 +33,7 @@ impl LanguageModelSelector {
let all_models = Self::all_models(cx); let all_models = Self::all_models(cx);
let delegate = LanguageModelPickerDelegate { let delegate = LanguageModelPickerDelegate {
language_model_selector: cx.model().downgrade(), language_model_selector: cx.entity().downgrade(),
on_model_changed: on_model_changed.clone(), on_model_changed: on_model_changed.clone(),
all_models: all_models.clone(), all_models: all_models.clone(),
filtered_models: all_models, filtered_models: all_models,

View file

@ -124,7 +124,7 @@ impl RefreshLlmTokenListener {
fn new(client: Arc<Client>, cx: &mut Context<Self>) -> Self { fn new(client: Arc<Client>, cx: &mut Context<Self>) -> Self {
Self { Self {
_llm_token_subscription: client _llm_token_subscription: client
.add_message_handler(cx.weak_model(), Self::handle_refresh_llm_token), .add_message_handler(cx.weak_entity(), Self::handle_refresh_llm_token),
} }
} }

View file

@ -67,7 +67,7 @@ impl LanguageSelector {
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let delegate = LanguageSelectorDelegate::new( let delegate = LanguageSelectorDelegate::new(
cx.model().downgrade(), cx.entity().downgrade(),
buffer, buffer,
project, project,
language_registry, language_registry,

View file

@ -242,7 +242,7 @@ impl LogStore {
if let copilot::Event::CopilotLanguageServerStarted = inline_completion_event { if let copilot::Event::CopilotLanguageServerStarted = inline_completion_event {
if let Some(server) = copilot.read(cx).language_server() { if let Some(server) = copilot.read(cx).language_server() {
let server_id = server.server_id(); let server_id = server.server_id();
let weak_this = cx.weak_model(); let weak_this = cx.weak_entity();
this.copilot_log_subscription = this.copilot_log_subscription =
Some(server.on_notification::<copilot::request::LogMessage, _>( Some(server.on_notification::<copilot::request::LogMessage, _>(
move |params, mut cx| { move |params, mut cx| {
@ -926,7 +926,7 @@ impl LspLogView {
.expect("log buffer should be a singleton") .expect("log buffer should be a singleton")
.update(cx, |_, cx| { .update(cx, |_, cx| {
cx.spawn({ cx.spawn({
let buffer = cx.model(); let buffer = cx.entity();
|_, mut cx| async move { |_, mut cx| async move {
let language = language.await.ok(); let language = language.await.ok();
buffer.update(&mut cx, |buffer, cx| { buffer.update(&mut cx, |buffer, cx| {
@ -1222,7 +1222,7 @@ impl Render for LspLogToolbarItemView {
) )
}) })
.collect(); .collect();
let log_toolbar_view = cx.model().clone(); let log_toolbar_view = cx.entity().clone();
let lsp_menu = PopoverMenu::new("LspLogView") let lsp_menu = PopoverMenu::new("LspLogView")
.anchor(Corner::TopLeft) .anchor(Corner::TopLeft)
.trigger(Button::new( .trigger(Button::new(

View file

@ -303,7 +303,7 @@ impl Render for SyntaxTreeView {
{ {
let layer = layer.clone(); let layer = layer.clone();
rendered = rendered.child(uniform_list( rendered = rendered.child(uniform_list(
cx.model().clone(), cx.entity().clone(),
"SyntaxTreeView", "SyntaxTreeView",
layer.node().descendant_count(), layer.node().descendant_count(),
move |this, range, _, cx| { move |this, range, _, cx| {
@ -451,7 +451,7 @@ impl SyntaxTreeToolbarItemView {
let active_layer = buffer_state.active_layer.clone()?; let active_layer = buffer_state.active_layer.clone()?;
let active_buffer = buffer_state.buffer.read(cx).snapshot(); let active_buffer = buffer_state.buffer.read(cx).snapshot();
let view = cx.model().clone(); let view = cx.entity().clone();
Some( Some(
PopoverMenu::new("Syntax Tree") PopoverMenu::new("Syntax Tree")
.trigger(Self::render_header(&active_layer)) .trigger(Self::render_header(&active_layer))

View file

@ -219,7 +219,7 @@ impl Markdown {
impl Render for Markdown { impl Render for Markdown {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
MarkdownElement::new( MarkdownElement::new(
cx.model().clone(), cx.entity().clone(),
self.style.clone(), self.style.clone(),
self.language_registry.clone(), self.language_registry.clone(),
self.fallback_code_block_language.clone(), self.fallback_code_block_language.clone(),

View file

@ -144,7 +144,7 @@ impl MarkdownPreviewView {
cx: &mut Context<Workspace>, cx: &mut Context<Workspace>,
) -> Entity<Self> { ) -> Entity<Self> {
cx.new(|cx| { cx.new(|cx| {
let view = cx.model().downgrade(); let view = cx.entity().downgrade();
let list_state = ListState::new( let list_state = ListState::new(
0, 0,

View file

@ -103,9 +103,9 @@ impl NotificationStore {
channel_messages: Default::default(), channel_messages: Default::default(),
_watch_connection_status: watch_connection_status, _watch_connection_status: watch_connection_status,
_subscriptions: vec![ _subscriptions: vec![
client.add_message_handler(cx.weak_model(), Self::handle_new_notification), client.add_message_handler(cx.weak_entity(), Self::handle_new_notification),
client.add_message_handler(cx.weak_model(), Self::handle_delete_notification), client.add_message_handler(cx.weak_entity(), Self::handle_delete_notification),
client.add_message_handler(cx.weak_model(), Self::handle_update_notification), client.add_message_handler(cx.weak_entity(), Self::handle_update_notification),
], ],
user_store, user_store,
client, client,

View file

@ -88,7 +88,7 @@ impl Render for OutlineView {
impl OutlineView { impl OutlineView {
fn register(editor: &mut Editor, _: Option<&mut Window>, cx: &mut Context<Editor>) { fn register(editor: &mut Editor, _: Option<&mut Window>, cx: &mut Context<Editor>) {
if editor.mode() == EditorMode::Full { if editor.mode() == EditorMode::Full {
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
editor editor
.register_action(move |action, window, cx| { .register_action(move |action, window, cx| {
if let Some(editor) = handle.upgrade() { if let Some(editor) = handle.upgrade() {
@ -105,7 +105,7 @@ impl OutlineView {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> OutlineView { ) -> OutlineView {
let delegate = OutlineViewDelegate::new(cx.model().downgrade(), outline, editor, cx); let delegate = OutlineViewDelegate::new(cx.entity().downgrade(), outline, editor, cx);
let picker = cx.new(|cx| { let picker = cx.new(|cx| {
Picker::uniform_list(delegate, window, cx).max_height(Some(vh(0.75, window))) Picker::uniform_list(delegate, window, cx).max_height(Some(vh(0.75, window)))
}); });

View file

@ -709,7 +709,7 @@ impl OutlinePanel {
cx: &mut Context<Workspace>, cx: &mut Context<Workspace>,
) -> Entity<Self> { ) -> Entity<Self> {
let project = workspace.project().clone(); let project = workspace.project().clone();
let workspace_handle = cx.model().downgrade(); let workspace_handle = cx.entity().downgrade();
let outline_panel = cx.new(|cx| { let outline_panel = cx.new(|cx| {
let filter_editor = cx.new(|cx| { let filter_editor = cx.new(|cx| {
let mut editor = Editor::single_line(window, cx); let mut editor = Editor::single_line(window, cx);
@ -796,9 +796,9 @@ impl OutlinePanel {
show_scrollbar: !Self::should_autohide_scrollbar(cx), show_scrollbar: !Self::should_autohide_scrollbar(cx),
hide_scrollbar_task: None, hide_scrollbar_task: None,
vertical_scrollbar_state: ScrollbarState::new(scroll_handle.clone()) vertical_scrollbar_state: ScrollbarState::new(scroll_handle.clone())
.parent_model(&cx.model()), .parent_model(&cx.entity()),
horizontal_scrollbar_state: ScrollbarState::new(scroll_handle.clone()) horizontal_scrollbar_state: ScrollbarState::new(scroll_handle.clone())
.parent_model(&cx.model()), .parent_model(&cx.entity()),
max_width_item_index: None, max_width_item_index: None,
scroll_handle, scroll_handle,
focus_handle, focus_handle,
@ -4467,7 +4467,7 @@ impl OutlinePanel {
let multi_buffer_snapshot = self let multi_buffer_snapshot = self
.active_editor() .active_editor()
.map(|editor| editor.read(cx).buffer().read(cx).snapshot(cx)); .map(|editor| editor.read(cx).buffer().read(cx).snapshot(cx));
uniform_list(cx.model().clone(), "entries", items_len, { uniform_list(cx.entity().clone(), "entries", items_len, {
move |outline_panel, range, window, cx| { move |outline_panel, range, window, cx| {
let entries = outline_panel.cached_entries.get(range); let entries = outline_panel.cached_entries.get(range);
entries entries
@ -4534,7 +4534,7 @@ impl OutlinePanel {
.when(show_indent_guides, |list| { .when(show_indent_guides, |list| {
list.with_decoration( list.with_decoration(
ui::indent_guides( ui::indent_guides(
cx.model().clone(), cx.entity().clone(),
px(indent_size), px(indent_size),
IndentGuideColors::panel(cx), IndentGuideColors::panel(cx),
|outline_panel, range, _, _| { |outline_panel, range, _, _| {
@ -4547,7 +4547,7 @@ impl OutlinePanel {
}, },
) )
.with_render_fn( .with_render_fn(
cx.model().clone(), cx.entity().clone(),
move |outline_panel, params, _, _| { move |outline_panel, params, _, _| {
const LEFT_OFFSET: f32 = 14.; const LEFT_OFFSET: f32 = 14.;

View file

@ -281,7 +281,7 @@ impl<D: PickerDelegate> Picker<D> {
ElementContainer::UniformList(UniformListScrollHandle::new()) ElementContainer::UniformList(UniformListScrollHandle::new())
} }
ContainerKind::List => { ContainerKind::List => {
let model = cx.model().downgrade(); let model = cx.entity().downgrade();
ElementContainer::List(ListState::new( ElementContainer::List(ListState::new(
0, 0,
gpui::ListAlignment::Top, gpui::ListAlignment::Top,
@ -643,7 +643,7 @@ impl<D: PickerDelegate> Picker<D> {
}; };
match &self.element_container { match &self.element_container {
ElementContainer::UniformList(scroll_handle) => uniform_list( ElementContainer::UniformList(scroll_handle) => uniform_list(
cx.model().clone(), cx.entity().clone(),
"candidates", "candidates",
self.delegate.match_count(), self.delegate.match_count(),
move |picker, visible_range, window, cx| { move |picker, visible_range, window, cx| {

View file

@ -687,7 +687,7 @@ impl LocalBufferStore {
buffer_id, buffer_id,
); );
events.push(BufferStoreEvent::BufferChangedFilePath { events.push(BufferStoreEvent::BufferChangedFilePath {
buffer: cx.model(), buffer: cx.entity(),
old_file: buffer.file().cloned(), old_file: buffer.file().cloned(),
}); });
} }
@ -875,7 +875,7 @@ impl LocalBufferStore {
if !push_to_history { if !push_to_history {
buffer.forget_transaction(transaction.id); buffer.forget_transaction(transaction.id);
} }
project_transaction.0.insert(cx.model(), transaction); project_transaction.0.insert(cx.entity(), transaction);
} }
})?; })?;
} }
@ -1302,7 +1302,7 @@ impl BufferStore {
unstaged_changes: None, unstaged_changes: None,
}; };
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
buffer.update(cx, move |_, cx| { buffer.update(cx, move |_, cx| {
cx.on_release(move |buffer, cx| { cx.on_release(move |buffer, cx| {
handle handle

View file

@ -39,7 +39,7 @@ impl Manager {
project: &Entity<Project>, project: &Entity<Project>,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
let manager = cx.weak_model(); let manager = cx.weak_entity();
project.update(cx, |_, cx| { project.update(cx, |_, cx| {
let manager = manager.clone(); let manager = manager.clone();
cx.on_release(move |project, cx| { cx.on_release(move |project, cx| {

View file

@ -122,7 +122,7 @@ impl GitState {
let mut new_repositories = Vec::new(); let mut new_repositories = Vec::new();
let mut new_active_index = None; let mut new_active_index = None;
let this = cx.weak_model(); let this = cx.weak_entity();
worktree_store.update(cx, |worktree_store, cx| { worktree_store.update(cx, |worktree_store, cx| {
for worktree in worktree_store.worktrees() { for worktree in worktree_store.worktrees() {

View file

@ -203,7 +203,7 @@ pub struct ImageStore {
impl ImageStore { impl ImageStore {
pub fn local(worktree_store: Entity<WorktreeStore>, cx: &mut Context<Self>) -> Self { pub fn local(worktree_store: Entity<WorktreeStore>, cx: &mut Context<Self>) -> Self {
let this = cx.weak_model(); let this = cx.weak_entity();
Self { Self {
state: Box::new(cx.new(|cx| { state: Box::new(cx.new(|cx| {
let subscription = cx.subscribe( let subscription = cx.subscribe(

View file

@ -417,7 +417,7 @@ impl LocalLspStore {
let delegate = LocalLspAdapterDelegate::new( let delegate = LocalLspAdapterDelegate::new(
self.languages.clone(), self.languages.clone(),
&self.environment, &self.environment,
cx.weak_model(), cx.weak_entity(),
&worktree, &worktree,
self.http_client.clone(), self.http_client.clone(),
self.fs.clone(), self.fs.clone(),
@ -5153,7 +5153,7 @@ impl LspStore {
let delegate = LocalLspAdapterDelegate::new( let delegate = LocalLspAdapterDelegate::new(
local.languages.clone(), local.languages.clone(),
&local.environment, &local.environment,
cx.weak_model(), cx.weak_entity(),
&worktree, &worktree,
local.http_client.clone(), local.http_client.clone(),
local.fs.clone(), local.fs.clone(),
@ -8159,7 +8159,7 @@ impl LanguageServerWatchedPathsBuilder {
language_server_id: LanguageServerId, language_server_id: LanguageServerId,
cx: &mut Context<LspStore>, cx: &mut Context<LspStore>,
) -> LanguageServerWatchedPaths { ) -> LanguageServerWatchedPaths {
let project = cx.weak_model(); let project = cx.weak_entity();
const LSP_ABS_PATH_OBSERVE: Duration = Duration::from_millis(100); const LSP_ABS_PATH_OBSERVE: Duration = Duration::from_millis(100);
let abs_paths = self let abs_paths = self

View file

@ -869,7 +869,7 @@ impl Project {
}; };
let ssh = ssh.read(cx); let ssh = ssh.read(cx);
ssh.subscribe_to_entity(SSH_PROJECT_ID, &cx.model()); ssh.subscribe_to_entity(SSH_PROJECT_ID, &cx.entity());
ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.buffer_store); ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.buffer_store);
ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.worktree_store); ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.worktree_store);
ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.lsp_store); ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.lsp_store);
@ -1585,7 +1585,7 @@ impl Project {
self.client_subscriptions.extend([ self.client_subscriptions.extend([
self.client self.client
.subscribe_to_entity(project_id)? .subscribe_to_entity(project_id)?
.set_model(&cx.model(), &mut cx.to_async()), .set_model(&cx.entity(), &mut cx.to_async()),
self.client self.client
.subscribe_to_entity(project_id)? .subscribe_to_entity(project_id)?
.set_model(&self.worktree_store, &mut cx.to_async()), .set_model(&self.worktree_store, &mut cx.to_async()),
@ -2427,7 +2427,7 @@ impl Project {
delay delay
} else { } else {
if first_insertion { if first_insertion {
let this = cx.weak_model(); let this = cx.weak_entity();
cx.defer(move |cx| { cx.defer(move |cx| {
if let Some(this) = this.upgrade() { if let Some(this) = this.upgrade() {
this.update(cx, |this, cx| { this.update(cx, |this, cx| {

View file

@ -401,9 +401,9 @@ impl ProjectPanel {
show_scrollbar: !Self::should_autohide_scrollbar(cx), show_scrollbar: !Self::should_autohide_scrollbar(cx),
hide_scrollbar_task: None, hide_scrollbar_task: None,
vertical_scrollbar_state: ScrollbarState::new(scroll_handle.clone()) vertical_scrollbar_state: ScrollbarState::new(scroll_handle.clone())
.parent_model(&cx.model()), .parent_model(&cx.entity()),
horizontal_scrollbar_state: ScrollbarState::new(scroll_handle.clone()) horizontal_scrollbar_state: ScrollbarState::new(scroll_handle.clone())
.parent_model(&cx.model()), .parent_model(&cx.entity()),
max_width_item_index: None, max_width_item_index: None,
diagnostics: Default::default(), diagnostics: Default::default(),
scroll_handle, scroll_handle,
@ -4227,7 +4227,7 @@ impl Render for ProjectPanel {
) )
.track_focus(&self.focus_handle(cx)) .track_focus(&self.focus_handle(cx))
.child( .child(
uniform_list(cx.model().clone(), "entries", item_count, { uniform_list(cx.entity().clone(), "entries", item_count, {
|this, range, window, cx| { |this, range, window, cx| {
let mut items = Vec::with_capacity(range.end - range.start); let mut items = Vec::with_capacity(range.end - range.start);
this.for_each_visible_entry( this.for_each_visible_entry(
@ -4244,7 +4244,7 @@ impl Render for ProjectPanel {
.when(show_indent_guides, |list| { .when(show_indent_guides, |list| {
list.with_decoration( list.with_decoration(
ui::indent_guides( ui::indent_guides(
cx.model().clone(), cx.entity().clone(),
px(indent_size), px(indent_size),
IndentGuideColors::panel(cx), IndentGuideColors::panel(cx),
|this, range, window, cx| { |this, range, window, cx| {
@ -4287,7 +4287,7 @@ impl Render for ProjectPanel {
}, },
)) ))
.with_render_fn( .with_render_fn(
cx.model().clone(), cx.entity().clone(),
move |this, params, _, cx| { move |this, params, _, cx| {
const LEFT_OFFSET: f32 = 14.; const LEFT_OFFSET: f32 = 14.;
const PADDING_Y: f32 = 4.; const PADDING_Y: f32 = 4.;

View file

@ -21,7 +21,7 @@ pub fn init(cx: &mut App) {
workspace.register_action( workspace.register_action(
|workspace, _: &workspace::ToggleProjectSymbols, window, cx| { |workspace, _: &workspace::ToggleProjectSymbols, window, cx| {
let project = workspace.project().clone(); let project = workspace.project().clone();
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
workspace.toggle_modal(window, cx, move |window, cx| { workspace.toggle_modal(window, cx, move |window, cx| {
let delegate = ProjectSymbolsDelegate::new(handle, project); let delegate = ProjectSymbolsDelegate::new(handle, project);
Picker::uniform_list(delegate, window, cx).width(rems(34.)) Picker::uniform_list(delegate, window, cx).width(rems(34.))

View file

@ -64,7 +64,7 @@ impl DisconnectedOverlay {
) { ) {
return; return;
} }
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
let ssh_connection_options = project.read(cx).ssh_connection_options(cx); let ssh_connection_options = project.read(cx).ssh_connection_options(cx);
let host = if let Some(ssh_connection_options) = ssh_connection_options { let host = if let Some(ssh_connection_options) = ssh_connection_options {

View file

@ -109,7 +109,7 @@ impl RecentProjects {
window: &mut Window, window: &mut Window,
cx: &mut Context<Workspace>, cx: &mut Context<Workspace>,
) { ) {
let weak = cx.model().downgrade(); let weak = cx.entity().downgrade();
workspace.toggle_modal(window, cx, |window, cx| { workspace.toggle_modal(window, cx, |window, cx| {
let delegate = RecentProjectsDelegate::new(weak, create_new_window, true); let delegate = RecentProjectsDelegate::new(weak, create_new_window, true);

View file

@ -145,7 +145,7 @@ impl ProjectPicker {
let Ok(Some(paths)) = rx.await else { let Ok(Some(paths)) = rx.await else {
workspace workspace
.update_in(&mut cx, |workspace, window, cx| { .update_in(&mut cx, |workspace, window, cx| {
let weak = cx.model().downgrade(); let weak = cx.entity().downgrade();
workspace.toggle_modal(window, cx, |window, cx| { workspace.toggle_modal(window, cx, |window, cx| {
RemoteServerProjects::new(window, cx, weak) RemoteServerProjects::new(window, cx, weak)
}); });
@ -326,14 +326,14 @@ impl RemoteServerProjects {
_: &mut Context<Workspace>, _: &mut Context<Workspace>,
) { ) {
workspace.register_action(|workspace, _: &OpenRemote, window, cx| { workspace.register_action(|workspace, _: &OpenRemote, window, cx| {
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
workspace.toggle_modal(window, cx, |window, cx| Self::new(window, cx, handle)) workspace.toggle_modal(window, cx, |window, cx| Self::new(window, cx, handle))
}); });
} }
pub fn open(workspace: Entity<Workspace>, window: &mut Window, cx: &mut App) { pub fn open(workspace: Entity<Workspace>, window: &mut Window, cx: &mut App) {
workspace.update(cx, |workspace, cx| { workspace.update(cx, |workspace, cx| {
let handle = cx.model().downgrade(); let handle = cx.entity().downgrade();
workspace.toggle_modal(window, cx, |window, cx| Self::new(window, cx, handle)) workspace.toggle_modal(window, cx, |window, cx| Self::new(window, cx, handle))
}) })
} }
@ -523,7 +523,7 @@ impl RemoteServerProjects {
let Some(Some(session)) = session else { let Some(Some(session)) = session else {
workspace workspace
.update_in(&mut cx, |workspace, window, cx| { .update_in(&mut cx, |workspace, window, cx| {
let weak = cx.model().downgrade(); let weak = cx.entity().downgrade();
workspace.toggle_modal(window, cx, |window, cx| { workspace.toggle_modal(window, cx, |window, cx| {
RemoteServerProjects::new(window, cx, weak) RemoteServerProjects::new(window, cx, weak)
}); });
@ -535,7 +535,7 @@ impl RemoteServerProjects {
workspace workspace
.update_in(&mut cx, |workspace, window, cx| { .update_in(&mut cx, |workspace, window, cx| {
let app_state = workspace.app_state().clone(); let app_state = workspace.app_state().clone();
let weak = cx.model().downgrade(); let weak = cx.entity().downgrade();
let project = project::Project::ssh( let project = project::Project::ssh(
session, session,
app_state.client.clone(), app_state.client.clone(),
@ -1152,7 +1152,7 @@ impl RemoteServerProjects {
let connection_string = connection_string.clone(); let connection_string = connection_string.clone();
move |_, _: &menu::Confirm, window, cx| { move |_, _: &menu::Confirm, window, cx| {
remove_ssh_server( remove_ssh_server(
cx.model().clone(), cx.entity().clone(),
server_index, server_index,
connection_string.clone(), connection_string.clone(),
window, window,
@ -1172,7 +1172,7 @@ impl RemoteServerProjects {
.child(Label::new("Remove Server").color(Color::Error)) .child(Label::new("Remove Server").color(Color::Error))
.on_click(cx.listener(move |_, _, window, cx| { .on_click(cx.listener(move |_, _, window, cx| {
remove_ssh_server( remove_ssh_server(
cx.model().clone(), cx.entity().clone(),
server_index, server_index,
connection_string.clone(), connection_string.clone(),
window, window,
@ -1280,7 +1280,7 @@ impl RemoteServerProjects {
state = new_state.clone(); state = new_state.clone();
} }
} }
let scroll_state = state.scrollbar.parent_model(&cx.model()); let scroll_state = state.scrollbar.parent_model(&cx.entity());
let connect_button = div() let connect_button = div()
.id("ssh-connect-new-server-container") .id("ssh-connect-new-server-container")
.track_focus(&state.add_new_server.focus_handle) .track_focus(&state.add_new_server.focus_handle)

View file

@ -166,19 +166,19 @@ impl HeadlessProject {
session.subscribe_to_entity(SSH_PROJECT_ID, &worktree_store); session.subscribe_to_entity(SSH_PROJECT_ID, &worktree_store);
session.subscribe_to_entity(SSH_PROJECT_ID, &buffer_store); session.subscribe_to_entity(SSH_PROJECT_ID, &buffer_store);
session.subscribe_to_entity(SSH_PROJECT_ID, &cx.model()); session.subscribe_to_entity(SSH_PROJECT_ID, &cx.entity());
session.subscribe_to_entity(SSH_PROJECT_ID, &lsp_store); session.subscribe_to_entity(SSH_PROJECT_ID, &lsp_store);
session.subscribe_to_entity(SSH_PROJECT_ID, &task_store); session.subscribe_to_entity(SSH_PROJECT_ID, &task_store);
session.subscribe_to_entity(SSH_PROJECT_ID, &toolchain_store); session.subscribe_to_entity(SSH_PROJECT_ID, &toolchain_store);
session.subscribe_to_entity(SSH_PROJECT_ID, &settings_observer); session.subscribe_to_entity(SSH_PROJECT_ID, &settings_observer);
client.add_request_handler(cx.weak_model(), Self::handle_list_remote_directory); client.add_request_handler(cx.weak_entity(), Self::handle_list_remote_directory);
client.add_request_handler(cx.weak_model(), Self::handle_get_path_metadata); client.add_request_handler(cx.weak_entity(), Self::handle_get_path_metadata);
client.add_request_handler(cx.weak_model(), Self::handle_shutdown_remote_server); client.add_request_handler(cx.weak_entity(), Self::handle_shutdown_remote_server);
client.add_request_handler(cx.weak_model(), Self::handle_ping); client.add_request_handler(cx.weak_entity(), Self::handle_ping);
client.add_model_request_handler(Self::handle_add_worktree); client.add_model_request_handler(Self::handle_add_worktree);
client.add_request_handler(cx.weak_model(), Self::handle_remove_worktree); client.add_request_handler(cx.weak_entity(), Self::handle_remove_worktree);
client.add_model_request_handler(Self::handle_open_buffer_by_path); client.add_model_request_handler(Self::handle_open_buffer_by_path);
client.add_model_request_handler(Self::handle_open_new_buffer); client.add_model_request_handler(Self::handle_open_new_buffer);

View file

@ -113,10 +113,10 @@ impl NotebookEditor {
); );
} }
let notebook_handle = cx.model().downgrade(); let notebook_handle = cx.entity().downgrade();
let cell_count = cell_order.len(); let cell_count = cell_order.len();
let this = cx.model(); let this = cx.entity();
let cell_list = ListState::new( let cell_list = ListState::new(
cell_count, cell_count,
gpui::ListAlignment::Top, gpui::ListAlignment::Top,

View file

@ -92,7 +92,7 @@ pub fn init(cx: &mut App) {
let project_path = buffer.and_then(|buffer| buffer.read(cx).project_path(cx)); let project_path = buffer.and_then(|buffer| buffer.read(cx).project_path(cx));
let editor_handle = cx.model().downgrade(); let editor_handle = cx.entity().downgrade();
if let Some(language) = language { if let Some(language) = language {
if language.name() == "Python".into() { if language.name() == "Python".into() {

View file

@ -245,7 +245,7 @@ impl Session {
repl_session_id = cx.entity_id().to_string(), repl_session_id = cx.entity_id().to_string(),
); );
let session_view = cx.model().clone(); let session_view = cx.entity().clone();
let kernel = match self.kernel_specification.clone() { let kernel = match self.kernel_specification.clone() {
KernelSpecification::Jupyter(kernel_specification) KernelSpecification::Jupyter(kernel_specification)
@ -417,7 +417,7 @@ impl Session {
}; };
let parent_message_id = message.header.msg_id.clone(); let parent_message_id = message.header.msg_id.clone();
let session_view = cx.model().downgrade(); let session_view = cx.entity().downgrade();
let weak_editor = self.editor.clone(); let weak_editor = self.editor.clone();
let on_close: CloseBlockFn = Arc::new( let on_close: CloseBlockFn = Arc::new(

View file

@ -516,7 +516,7 @@ impl ToolbarItemView for BufferSearchBar {
if let Some(searchable_item_handle) = if let Some(searchable_item_handle) =
item.and_then(|item| item.to_searchable_item_handle(cx)) item.and_then(|item| item.to_searchable_item_handle(cx))
{ {
let this = cx.model().downgrade(); let this = cx.entity().downgrade();
self.active_searchable_item_subscription = self.active_searchable_item_subscription =
Some(searchable_item_handle.subscribe_to_search_events( Some(searchable_item_handle.subscribe_to_search_events(

View file

@ -820,7 +820,7 @@ impl ProjectSearchView {
return; return;
}; };
let weak_workspace = cx.model().downgrade(); let weak_workspace = cx.entity().downgrade();
let model = cx.new(|cx| ProjectSearch::new(workspace.project().clone(), cx)); let model = cx.new(|cx| ProjectSearch::new(workspace.project().clone(), cx));
let search = cx.new(|cx| ProjectSearchView::new(weak_workspace, model, window, cx, None)); let search = cx.new(|cx| ProjectSearchView::new(weak_workspace, model, window, cx, None));
@ -879,7 +879,7 @@ impl ProjectSearchView {
model.search(new_query, cx); model.search(new_query, cx);
model model
}); });
let weak_workspace = cx.model().downgrade(); let weak_workspace = cx.entity().downgrade();
workspace.add_item_to_active_pane( workspace.add_item_to_active_pane(
Box::new( Box::new(
cx.new(|cx| { cx.new(|cx| {
@ -937,7 +937,7 @@ impl ProjectSearchView {
let settings = settings.cloned(); let settings = settings.cloned();
let weak_workspace = cx.model().downgrade(); let weak_workspace = cx.entity().downgrade();
let project_search = cx.new(|cx| ProjectSearch::new(workspace.project().clone(), cx)); let project_search = cx.new(|cx| ProjectSearch::new(workspace.project().clone(), cx));
let project_search_view = cx.new(|cx| { let project_search_view = cx.new(|cx| {

View file

@ -115,7 +115,7 @@ impl ProjectIndexDebugView {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
this.update(&mut cx, |this, cx| { this.update(&mut cx, |this, cx| {
let view = cx.model().downgrade(); let view = cx.entity().downgrade();
this.selected_path = Some(PathState { this.selected_path = Some(PathState {
path: file_path, path: file_path,
list_state: ListState::new( list_state: ListState::new(
@ -224,7 +224,7 @@ impl Render for ProjectIndexDebugView {
.into_any_element() .into_any_element()
} else { } else {
let mut list = uniform_list( let mut list = uniform_list(
cx.model().clone(), cx.entity().clone(),
"ProjectIndexDebugView", "ProjectIndexDebugView",
self.rows.len(), self.rows.len(),
move |this, range, _, cx| { move |this, range, _, cx| {

View file

@ -58,7 +58,7 @@ impl ScopeSelector {
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let delegate = let delegate =
ScopeSelectorDelegate::new(workspace, cx.model().downgrade(), language_registry); ScopeSelectorDelegate::new(workspace, cx.entity().downgrade(), language_registry);
let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx)); let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx));

View file

@ -39,7 +39,7 @@ impl Render for IndentGuidesStory {
.child( .child(
v_flex().size_full().child( v_flex().size_full().child(
uniform_list( uniform_list(
cx.model().clone(), cx.entity().clone(),
"some-list", "some-list",
self.depths.len(), self.depths.len(),
|this, range, cx| { |this, range, cx| {
@ -60,7 +60,7 @@ impl Render for IndentGuidesStory {
) )
.with_sizing_behavior(gpui::ListSizingBehavior::Infer) .with_sizing_behavior(gpui::ListSizingBehavior::Infer)
.with_decoration(ui::indent_guides( .with_decoration(ui::indent_guides(
cx.model().clone(), cx.entity().clone(),
px(16.), px(16.),
ui::IndentGuideColors { ui::IndentGuideColors {
default: Color::Info.color(cx), default: Color::Info.color(cx),

View file

@ -94,7 +94,7 @@ impl TabSwitcher {
let delegate = TabSwitcherDelegate::new( let delegate = TabSwitcherDelegate::new(
project, project,
action, action,
cx.model().downgrade(), cx.entity().downgrade(),
weak_pane, weak_pane,
window, window,
cx, cx,

View file

@ -903,7 +903,7 @@ pub fn new_terminal_pane(
cx: &mut Context<TerminalPanel>, cx: &mut Context<TerminalPanel>,
) -> Entity<Pane> { ) -> Entity<Pane> {
let is_local = project.read(cx).is_local(); let is_local = project.read(cx).is_local();
let terminal_panel = cx.model().clone(); let terminal_panel = cx.entity().clone();
let pane = cx.new(|cx| { let pane = cx.new(|cx| {
let mut pane = Pane::new( let mut pane = Pane::new(
workspace.clone(), workspace.clone(),
@ -923,7 +923,7 @@ pub fn new_terminal_pane(
let split_closure_terminal_panel = terminal_panel.downgrade(); let split_closure_terminal_panel = terminal_panel.downgrade();
pane.set_can_split(Some(Arc::new(move |pane, dragged_item, _window, cx| { pane.set_can_split(Some(Arc::new(move |pane, dragged_item, _window, cx| {
if let Some(tab) = dragged_item.downcast_ref::<DraggedTab>() { if let Some(tab) = dragged_item.downcast_ref::<DraggedTab>() {
let is_current_pane = tab.pane == cx.model(); let is_current_pane = tab.pane == cx.entity();
let Some(can_drag_away) = split_closure_terminal_panel let Some(can_drag_away) = split_closure_terminal_panel
.update(cx, |terminal_panel, _| { .update(cx, |terminal_panel, _| {
let current_panes = terminal_panel.center.panes(); let current_panes = terminal_panel.center.panes();
@ -963,7 +963,7 @@ pub fn new_terminal_pane(
return ControlFlow::Break(()); return ControlFlow::Break(());
}; };
if let Some(tab) = dropped_item.downcast_ref::<DraggedTab>() { if let Some(tab) = dropped_item.downcast_ref::<DraggedTab>() {
let this_pane = cx.model().clone(); let this_pane = cx.entity().clone();
let item = if tab.pane == this_pane { let item = if tab.pane == this_pane {
pane.item_for_index(tab.ix) pane.item_for_index(tab.ix)
} else { } else {

View file

@ -218,7 +218,7 @@ impl TerminalView {
} }
} }
pub fn model(&self) -> &Entity<Terminal> { pub fn entity(&self) -> &Entity<Terminal> {
&self.terminal &self.terminal
} }
@ -1125,7 +1125,7 @@ impl TerminalView {
impl Render for TerminalView { impl Render for TerminalView {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let terminal_handle = self.terminal.clone(); let terminal_handle = self.terminal.clone();
let terminal_view_handle = cx.model().clone(); let terminal_view_handle = cx.entity().clone();
let focused = self.focus_handle.is_focused(window); let focused = self.focus_handle.is_focused(window);
@ -1771,7 +1771,7 @@ mod tests {
let project = Project::test(params.fs.clone(), [], cx).await; let project = Project::test(params.fs.clone(), [], cx).await;
let workspace = cx let workspace = cx
.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx)) .add_window(|window, cx| Workspace::test_new(project.clone(), window, cx))
.root_model(cx) .root(cx)
.unwrap(); .unwrap();
(project, workspace) (project, workspace)

View file

@ -33,7 +33,7 @@ pub fn toggle(
let fs = workspace.app_state().fs.clone(); let fs = workspace.app_state().fs.clone();
workspace.toggle_modal(window, cx, |window, cx| { workspace.toggle_modal(window, cx, |window, cx| {
let delegate = ThemeSelectorDelegate::new( let delegate = ThemeSelectorDelegate::new(
cx.model().downgrade(), cx.entity().downgrade(),
fs, fs,
toggle.themes_filter.as_ref(), toggle.themes_filter.as_ref(),
cx, cx,

View file

@ -96,7 +96,7 @@ impl ToolchainSelector {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let toolchain_selector = cx.model().downgrade(); let toolchain_selector = cx.entity().downgrade();
let picker = cx.new(|cx| { let picker = cx.new(|cx| {
let delegate = ToolchainSelectorDelegate::new( let delegate = ToolchainSelectorDelegate::new(
active_toolchain, active_toolchain,

View file

@ -539,7 +539,7 @@ impl Render for ContextMenu {
disabled, disabled,
}) => { }) => {
let handler = handler.clone(); let handler = handler.clone();
let menu = cx.model().downgrade(); let menu = cx.entity().downgrade();
let icon_color = if *disabled { let icon_color = if *disabled {
Color::Muted Color::Muted
} else { } else {
@ -637,7 +637,7 @@ impl Render for ContextMenu {
selectable, selectable,
} => { } => {
let handler = handler.clone(); let handler = handler.clone();
let menu = cx.model().downgrade(); let menu = cx.entity().downgrade();
let selectable = *selectable; let selectable = *selectable;
ListItem::new(ix) ListItem::new(ix)
.inset(true) .inset(true)

View file

@ -35,7 +35,7 @@ impl BranchList {
window: &mut Window, window: &mut Window,
cx: &mut Context<Workspace>, cx: &mut Context<Workspace>,
) { ) {
let this = cx.model().clone(); let this = cx.entity().clone();
cx.spawn_in(window, |_, mut cx| async move { cx.spawn_in(window, |_, mut cx| async move {
// Modal branch picker has a longer trailoff than a popover one. // Modal branch picker has a longer trailoff than a popover one.
let delegate = BranchListDelegate::new(this.clone(), 70, &cx).await?; let delegate = BranchListDelegate::new(this.clone(), 70, &cx).await?;

View file

@ -20,7 +20,7 @@ impl ModeIndicator {
}) })
.detach(); .detach();
let handle = cx.model().clone(); let handle = cx.entity().clone();
let window_handle = window.window_handle(); let window_handle = window.window_handle();
cx.observe_new::<Vim>(move |_, window, cx| { cx.observe_new::<Vim>(move |_, window, cx| {
let Some(window) = window else { let Some(window) = window else {
@ -29,7 +29,7 @@ impl ModeIndicator {
if window.window_handle() != window_handle { if window.window_handle() != window_handle {
return; return;
} }
let vim = cx.model().clone(); let vim = cx.entity().clone();
handle.update(cx, |_, cx| { handle.update(cx, |_, cx| {
cx.subscribe(&vim, |mode_indicator, vim, event, cx| match event { cx.subscribe(&vim, |mode_indicator, vim, event, cx| match event {
VimEvent::Focused => { VimEvent::Focused => {

View file

@ -130,7 +130,7 @@ impl Replayer {
text, text,
utf16_range_to_replace, utf16_range_to_replace,
} => { } => {
let Some(Some(workspace)) = window.root_model::<Workspace>() else { let Some(Some(workspace)) = window.root::<Workspace>() else {
return; return;
}; };
let Some(editor) = workspace let Some(editor) = workspace

Some files were not shown because too many files have changed in this diff Show more