diff --git a/crates/activity_indicator/src/activity_indicator.rs b/crates/activity_indicator/src/activity_indicator.rs index 8c6f5aa176..7a86e50196 100644 --- a/crates/activity_indicator/src/activity_indicator.rs +++ b/crates/activity_indicator/src/activity_indicator.rs @@ -473,7 +473,7 @@ impl Render for ActivityIndicator { let Some(content) = self.content_to_render(cx) else { return result; }; - let this = cx.model().downgrade(); + let this = cx.entity().downgrade(); let truncate_content = content.message.len() > MAX_MESSAGE_LEN; result.gap_2().child( PopoverMenu::new("activity-indicator-popover") diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index bcd55b7a26..7780424e85 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -155,7 +155,7 @@ impl AssistantPanel { let project_paths = if let Some(tab) = dropped_item.downcast_ref::() { - if tab.pane == cx.model() { + if tab.pane == cx.entity() { return None; } let item = tab.pane.read(cx).item_for_index(tab.ix); @@ -231,7 +231,7 @@ impl AssistantPanel { pane.active_item() .map_or(false, |item| item.downcast::().is_some()), ); - let _pane = cx.model().clone(); + let _pane = cx.entity().clone(); let right_children = h_flex() .gap(DynamicSpacing::Base02.rems(cx)) .child( @@ -617,7 +617,7 @@ impl AssistantPanel { InlineAssistant::update_global(cx, |assistant, cx| { assistant.assist( &active_editor, - Some(cx.model().downgrade()), + Some(cx.entity().downgrade()), include_context.then_some(&assistant_panel), initial_prompt, window, @@ -629,7 +629,7 @@ impl AssistantPanel { TerminalInlineAssistant::update_global(cx, |assistant, cx| { assistant.assist( &active_terminal, - Some(cx.model().downgrade()), + Some(cx.entity().downgrade()), Some(&assistant_panel), initial_prompt, window, diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rs index 94dd220f17..808054d046 100644 --- a/crates/assistant/src/inline_assistant.rs +++ b/crates/assistant/src/inline_assistant.rs @@ -77,7 +77,7 @@ pub fn init( let Some(window) = window else { return; }; - let workspace = cx.model().clone(); + let workspace = cx.entity().clone(); InlineAssistant::update_global(cx, |inline_assistant, cx| { inline_assistant.register_workspace(&workspace, window, cx) }); @@ -211,7 +211,7 @@ impl InlineAssistant { } else { editor.add_code_action_provider( Rc::new(AssistantCodeActionProvider { - editor: cx.model().downgrade(), + editor: cx.entity().downgrade(), workspace: workspace.downgrade(), }), window, @@ -1345,7 +1345,7 @@ impl EditorInlineAssists { }) }), 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| { InlineAssistant::update_global(cx, |this, cx| { if let Some(editor) = editor_handle.upgrade() { @@ -1355,7 +1355,7 @@ impl EditorInlineAssists { }) }), 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| { InlineAssistant::update_global(cx, |this, cx| { if let Some(editor) = editor_handle.upgrade() { diff --git a/crates/assistant/src/terminal_inline_assistant.rs b/crates/assistant/src/terminal_inline_assistant.rs index 6f2bb6fdba..4547ea8e67 100644 --- a/crates/assistant/src/terminal_inline_assistant.rs +++ b/crates/assistant/src/terminal_inline_assistant.rs @@ -242,7 +242,7 @@ impl TerminalInlineAssistant { let (latest_output, working_directory) = assist .terminal .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 working_directory = terminal .working_directory() diff --git a/crates/assistant2/src/active_thread.rs b/crates/assistant2/src/active_thread.rs index 3cade8f003..369e1408a7 100644 --- a/crates/assistant2/src/active_thread.rs +++ b/crates/assistant2/src/active_thread.rs @@ -56,7 +56,7 @@ impl ActiveThread { messages: Vec::new(), rendered_messages_by_id: HashMap::default(), 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| { this.update(cx, |this, cx| this.render_message(ix, cx)) .unwrap() diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rs index 07593e8d75..032e40e13a 100644 --- a/crates/assistant2/src/assistant_panel.rs +++ b/crates/assistant2/src/assistant_panel.rs @@ -158,7 +158,7 @@ impl AssistantPanel { let project = workspace.project().clone(); let language_registry = project.read(cx).languages().clone(); let workspace = workspace.weak_handle(); - let weak_self = cx.model().downgrade(); + let weak_self = cx.entity().downgrade(); let message_editor = cx.new(|cx| { MessageEditor::new( @@ -811,7 +811,7 @@ impl AssistantPanel { .child(v_flex().mx_auto().w_4_5().gap_2().children( recent_threads.into_iter().map(|thread| { // TODO: keyboard navigation - PastThread::new(thread, cx.model().downgrade(), false) + PastThread::new(thread, cx.entity().downgrade(), false) }), )) .child( diff --git a/crates/assistant2/src/context_picker.rs b/crates/assistant2/src/context_picker.rs index 51f23edc2f..89bc09ea6d 100644 --- a/crates/assistant2/src/context_picker.rs +++ b/crates/assistant2/src/context_picker.rs @@ -78,7 +78,7 @@ impl ContextPicker { } fn build_menu(&mut self, window: &mut Window, cx: &mut Context) -> Entity { - let context_picker = cx.model().clone(); + let context_picker = cx.entity().clone(); let menu = ContextMenu::build(window, cx, move |menu, _window, 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) { - let context_picker = cx.model().downgrade(); + let context_picker = cx.entity().downgrade(); match kind { ContextKind::File => { diff --git a/crates/assistant2/src/context_strip.rs b/crates/assistant2/src/context_strip.rs index e0c2073021..97e9b633d3 100644 --- a/crates/assistant2/src/context_strip.rs +++ b/crates/assistant2/src/context_strip.rs @@ -393,7 +393,7 @@ impl Render for ContextStrip { .on_action(cx.listener(Self::remove_focused_context)) .on_action(cx.listener(Self::accept_suggested_context)) .on_children_prepainted({ - let model = cx.model().downgrade(); + let model = cx.entity().downgrade(); move |children_bounds, _window, cx| { model .update(cx, |this, _| { diff --git a/crates/assistant2/src/inline_assistant.rs b/crates/assistant2/src/inline_assistant.rs index 09fe77ec3b..a595341481 100644 --- a/crates/assistant2/src/inline_assistant.rs +++ b/crates/assistant2/src/inline_assistant.rs @@ -58,7 +58,7 @@ pub fn init( let Some(window) = window else { return; }; - let workspace = cx.model().clone(); + let workspace = cx.entity().clone(); InlineAssistant::update_global(cx, |inline_assistant, cx| { inline_assistant.register_workspace(&workspace, window, cx) }); @@ -196,7 +196,7 @@ impl InlineAssistant { editor.add_code_action_provider( Rc::new(AssistantCodeActionProvider { - editor: cx.model().downgrade(), + editor: cx.entity().downgrade(), workspace: workspace.downgrade(), thread_store, }), @@ -249,7 +249,7 @@ impl InlineAssistant { InlineAssistant::update_global(cx, |assistant, cx| { assistant.assist( &active_editor, - cx.model().downgrade(), + cx.entity().downgrade(), thread_store, window, cx, @@ -260,7 +260,7 @@ impl InlineAssistant { TerminalInlineAssistant::update_global(cx, |assistant, cx| { assistant.assist( &active_terminal, - cx.model().downgrade(), + cx.entity().downgrade(), thread_store, window, cx, @@ -1472,7 +1472,7 @@ impl EditorInlineAssists { }) }), 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| { InlineAssistant::update_global(cx, |this, cx| { if let Some(editor) = editor_handle.upgrade() { @@ -1482,7 +1482,7 @@ impl EditorInlineAssists { }) }), 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| { InlineAssistant::update_global(cx, |this, cx| { if let Some(editor) = editor_handle.upgrade() { diff --git a/crates/assistant2/src/terminal_inline_assistant.rs b/crates/assistant2/src/terminal_inline_assistant.rs index 1c74d87f3a..9abe2cbadb 100644 --- a/crates/assistant2/src/terminal_inline_assistant.rs +++ b/crates/assistant2/src/terminal_inline_assistant.rs @@ -222,7 +222,7 @@ impl TerminalInlineAssistant { let (latest_output, working_directory) = assist .terminal .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 working_directory = terminal .working_directory() diff --git a/crates/assistant2/src/thread_history.rs b/crates/assistant2/src/thread_history.rs index 9e77f3d94b..6e00d3db1c 100644 --- a/crates/assistant2/src/thread_history.rs +++ b/crates/assistant2/src/thread_history.rs @@ -154,7 +154,7 @@ impl Render for ThreadHistory { } else { history.child( uniform_list( - cx.model().clone(), + cx.entity().clone(), "thread-history", threads.len(), move |history, range, _window, _cx| { diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rs index 17ef04d84c..5d3e6f20a6 100644 --- a/crates/assistant_context_editor/src/context_editor.rs +++ b/crates/assistant_context_editor/src/context_editor.rs @@ -213,7 +213,7 @@ impl ContextEditor { ) -> Self { let completion_provider = SlashCommandCompletionProvider::new( context.read(cx).slash_commands().clone(), - Some(cx.model().downgrade()), + Some(cx.entity().downgrade()), Some(workspace.clone()), ); @@ -551,7 +551,7 @@ impl ContextEditor { window: &mut Window, cx: &mut Context, ) { - let context_editor = cx.model().downgrade(); + let context_editor = cx.entity().downgrade(); match event { ContextEvent::MessagesEdited => { @@ -605,7 +605,7 @@ impl ContextEditor { .map(|tool_use| { let placeholder = FoldPlaceholder { render: render_fold_icon_button( - cx.model().downgrade(), + cx.entity().downgrade(), IconName::PocketKnife, tool_use.name.clone().into(), ), @@ -789,7 +789,7 @@ impl ContextEditor { let placeholder = FoldPlaceholder { render: render_fold_icon_button( - cx.model().downgrade(), + cx.entity().downgrade(), IconName::PocketKnife, format!("Tool Result: {tool_use_id}").into(), ), @@ -937,7 +937,7 @@ impl ContextEditor { window: &mut Window, cx: &mut Context, ) { - let this = cx.model().downgrade(); + let this = cx.entity().downgrade(); let mut editors_to_close = Vec::new(); self.editor.update(cx, |editor, cx| { @@ -1081,7 +1081,7 @@ impl ContextEditor { start..end, FoldPlaceholder { render: render_fold_icon_button( - cx.model().downgrade(), + cx.entity().downgrade(), section.icon, section.label.clone(), ), @@ -1843,7 +1843,7 @@ impl ContextEditor { editor.insert("\n", window, cx); 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( anchor_before..anchor_after, fold_placeholder, @@ -2027,7 +2027,7 @@ impl ContextEditor { let buffer = editor.buffer().read(cx).snapshot(cx); let mut buffer_rows_to_fold = BTreeSet::new(); - let weak_editor = cx.model().downgrade(); + let weak_editor = cx.entity().downgrade(); editor.insert_creases( metadata.creases.into_iter().map(|metadata| { let start = buffer.anchor_after( @@ -2509,7 +2509,7 @@ impl ContextEditor { fn render_inject_context_menu(&self, cx: &mut Context) -> impl IntoElement { slash_command_picker::SlashCommandSelector::new( self.slash_commands.clone(), - cx.model().downgrade(), + cx.entity().downgrade(), Button::new("trigger", "Add Context") .icon(IconName::Plus) .icon_size(IconSize::Small) @@ -3699,7 +3699,7 @@ pub fn make_lsp_adapter_delegate( Ok(Some(LocalLspAdapterDelegate::new( project.languages().clone(), project.environment(), - cx.weak_model(), + cx.weak_entity(), &worktree, http_client, project.fs().clone(), diff --git a/crates/assistant_context_editor/src/context_store.rs b/crates/assistant_context_editor/src/context_store.rs index 55047ded7d..3ba3994858 100644 --- a/crates/assistant_context_editor/src/context_store.rs +++ b/crates/assistant_context_editor/src/context_store.rs @@ -318,7 +318,7 @@ impl ContextStore { .client .subscribe_to_entity(remote_id) .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); } else { self.client_subscription = None; diff --git a/crates/assistant_slash_commands/src/terminal_command.rs b/crates/assistant_slash_commands/src/terminal_command.rs index 2528c4f663..fe567e7501 100644 --- a/crates/assistant_slash_commands/src/terminal_command.rs +++ b/crates/assistant_slash_commands/src/terminal_command.rs @@ -85,7 +85,7 @@ impl SlashCommand for TerminalSlashCommand { let lines = active_terminal .read(cx) - .model() + .entity() .read(cx) .last_n_non_empty_lines(line_count); diff --git a/crates/breadcrumbs/src/breadcrumbs.rs b/crates/breadcrumbs/src/breadcrumbs.rs index fc9e6d96cd..29dde8618e 100644 --- a/crates/breadcrumbs/src/breadcrumbs.rs +++ b/crates/breadcrumbs/src/breadcrumbs.rs @@ -152,7 +152,7 @@ impl ToolbarItemView for Breadcrumbs { return ToolbarItemLocation::Hidden; }; - let this = cx.model().downgrade(); + let this = cx.entity().downgrade(); self.subscription = Some(item.subscribe_to_item_events( window, cx, diff --git a/crates/call/src/cross_platform/mod.rs b/crates/call/src/cross_platform/mod.rs index 53f70ee1e7..d361dd9dce 100644 --- a/crates/call/src/cross_platform/mod.rs +++ b/crates/call/src/cross_platform/mod.rs @@ -105,8 +105,8 @@ impl ActiveCall { incoming_call: watch::channel(), _join_debouncer: OneAtATime { cancel: None }, _subscriptions: vec![ - client.add_request_handler(cx.weak_model(), Self::handle_incoming_call), - client.add_message_handler(cx.weak_model(), Self::handle_call_canceled), + client.add_request_handler(cx.weak_entity(), Self::handle_incoming_call), + client.add_message_handler(cx.weak_entity(), Self::handle_call_canceled), ], client, user_store, diff --git a/crates/call/src/cross_platform/room.rs b/crates/call/src/cross_platform/room.rs index 167ac9f960..de7852a5a0 100644 --- a/crates/call/src/cross_platform/room.rs +++ b/crates/call/src/cross_platform/room.rs @@ -148,7 +148,7 @@ impl Room { pending_participants: Default::default(), pending_call_count: 0, 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![ cx.on_release(Self::released), diff --git a/crates/call/src/macos/mod.rs b/crates/call/src/macos/mod.rs index 1b8a19dd48..e6fb8c3cfb 100644 --- a/crates/call/src/macos/mod.rs +++ b/crates/call/src/macos/mod.rs @@ -98,8 +98,8 @@ impl ActiveCall { incoming_call: watch::channel(), _join_debouncer: OneAtATime { cancel: None }, _subscriptions: vec![ - client.add_request_handler(cx.weak_model(), Self::handle_incoming_call), - client.add_message_handler(cx.weak_model(), Self::handle_call_canceled), + client.add_request_handler(cx.weak_entity(), Self::handle_incoming_call), + client.add_message_handler(cx.weak_entity(), Self::handle_call_canceled), ], client, user_store, diff --git a/crates/call/src/macos/room.rs b/crates/call/src/macos/room.rs index bdaab8f8e9..b0c8ad9678 100644 --- a/crates/call/src/macos/room.rs +++ b/crates/call/src/macos/room.rs @@ -204,7 +204,7 @@ impl Room { pending_participants: Default::default(), pending_call_count: 0, 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![ cx.on_release(Self::released), diff --git a/crates/channel/src/channel_buffer.rs b/crates/channel/src/channel_buffer.rs index eb73a6f9d2..3ccfb0503c 100644 --- a/crates/channel/src/channel_buffer.rs +++ b/crates/channel/src/channel_buffer.rs @@ -81,7 +81,7 @@ impl ChannelBuffer { collaborators: Default::default(), acknowledge_task: None, 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, channel_store, }; diff --git a/crates/channel/src/channel_chat.rs b/crates/channel/src/channel_chat.rs index aad9868bd7..7707d300f7 100644 --- a/crates/channel/src/channel_chat.rs +++ b/crates/channel/src/channel_chat.rs @@ -132,7 +132,7 @@ impl ChannelChat { last_acknowledged_id: None, rng: StdRng::from_entropy(), 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( diff --git a/crates/channel/src/channel_store.rs b/crates/channel/src/channel_store.rs index 241a9d1952..8ba015f572 100644 --- a/crates/channel/src/channel_store.rs +++ b/crates/channel/src/channel_store.rs @@ -158,8 +158,8 @@ impl ChannelStore { pub fn new(client: Arc, user_store: Entity, cx: &mut Context) -> Self { let rpc_subscriptions = [ - client.add_message_handler(cx.weak_model(), 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_channels), + client.add_message_handler(cx.weak_entity(), Self::handle_update_user_channels), ]; let mut connection_status = client.status(); @@ -306,7 +306,7 @@ impl ChannelStore { ) -> Task>> { let client = self.client.clone(); let user_store = self.user_store.clone(); - let channel_store = cx.model(); + let channel_store = cx.entity(); self.open_channel_resource( channel_id, |this| &mut this.opened_buffers, @@ -436,7 +436,7 @@ impl ChannelStore { ) -> Task>> { let client = self.client.clone(); let user_store = self.user_store.clone(); - let this = cx.model(); + let this = cx.entity(); self.open_channel_resource( channel_id, |this| &mut this.opened_chats, diff --git a/crates/client/src/user.rs b/crates/client/src/user.rs index a99b519e03..91af9a1a7f 100644 --- a/crates/client/src/user.rs +++ b/crates/client/src/user.rs @@ -146,10 +146,10 @@ impl UserStore { let (mut current_user_tx, current_user_rx) = watch::channel(); let (update_contacts_tx, mut update_contacts_rx) = mpsc::unbounded(); let rpc_subscriptions = vec![ - client.add_message_handler(cx.weak_model(), Self::handle_update_plan), - client.add_message_handler(cx.weak_model(), Self::handle_update_contacts), - client.add_message_handler(cx.weak_model(), 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_update_plan), + client.add_message_handler(cx.weak_entity(), Self::handle_update_contacts), + client.add_message_handler(cx.weak_entity(), Self::handle_update_invite_info), + client.add_message_handler(cx.weak_entity(), Self::handle_show_contacts), ]; Self { users: Default::default(), @@ -262,7 +262,7 @@ impl UserStore { Ok(()) }), pending_contact_requests: Default::default(), - weak_self: cx.weak_model(), + weak_self: cx.weak_entity(), } } diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rs index bcfe9664c5..e35113c0c0 100644 --- a/crates/collab/src/tests/editor_tests.rs +++ b/crates/collab/src/tests/editor_tests.rs @@ -91,7 +91,7 @@ async fn test_host_disconnect( ) }); 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 .update(cx_b, |workspace, window, cx| { diff --git a/crates/collab/src/tests/notification_tests.rs b/crates/collab/src/tests/notification_tests.rs index eb1c56eeb8..cdec324632 100644 --- a/crates/collab/src/tests/notification_tests.rs +++ b/crates/collab/src/tests/notification_tests.rs @@ -21,14 +21,14 @@ async fn test_notifications( let notification_events_b = Arc::new(Mutex::new(Vec::new())); client_a.notification_store().update(cx_a, |_, cx| { let events = notification_events_a.clone(); - cx.subscribe(&cx.model(), move |_, _, event, _| { + cx.subscribe(&cx.entity(), move |_, _, event, _| { events.lock().push(event.clone()); }) .detach() }); client_b.notification_store().update(cx_b, |_, cx| { let events = notification_events_b.clone(); - cx.subscribe(&cx.model(), move |_, _, event, _| { + cx.subscribe(&cx.entity(), move |_, _, event, _| { events.lock().push(event.clone()); }) .detach() diff --git a/crates/collab/src/tests/test_server.rs b/crates/collab/src/tests/test_server.rs index 64e0319cbb..e3d2ffb079 100644 --- a/crates/collab/src/tests/test_server.rs +++ b/crates/collab/src/tests/test_server.rs @@ -849,7 +849,7 @@ impl TestClient { ) -> (Entity, &'a mut VisualTestContext) { let window = cx.update(|cx| cx.active_window().unwrap().downcast::().unwrap()); - let model = window.root_model(cx).unwrap(); + let model = window.root(cx).unwrap(); 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. (model, cx) @@ -861,7 +861,7 @@ pub fn open_channel_notes( cx: &mut VisualTestContext, ) -> Task>> { let window = cx.update(|_, cx| cx.active_window().unwrap().downcast::().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)) } diff --git a/crates/collab_ui/src/channel_view.rs b/crates/collab_ui/src/channel_view.rs index e1047ea366..a4e86a9f2f 100644 --- a/crates/collab_ui/src/channel_view.rs +++ b/crates/collab_ui/src/channel_view.rs @@ -204,7 +204,7 @@ impl ChannelView { cx: &mut Context, ) -> Self { let buffer = channel_buffer.read(cx).buffer(); - let this = cx.model().downgrade(); + let this = cx.entity().downgrade(); let editor = cx.new(|cx| { let mut editor = Editor::for_buffer(buffer, None, window, cx); editor.set_collaboration_hub(Box::new(ChannelBufferCollaborationHub( diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rs index 52b5e35a98..306bcd53bb 100644 --- a/crates/collab_ui/src/chat_panel.rs +++ b/crates/collab_ui/src/chat_panel.rs @@ -97,7 +97,7 @@ impl ChatPanel { }); cx.new(|cx| { - let model = cx.model().downgrade(); + let model = cx.entity().downgrade(); let message_list = ListState::new( 0, gpui::ListAlignment::Bottom, @@ -680,7 +680,7 @@ impl ChatPanel { }) }) .when_some(message_id, |el, message_id| { - let this = cx.model().clone(); + let this = cx.entity().clone(); el.child( self.render_popover_button( diff --git a/crates/collab_ui/src/chat_panel/message_editor.rs b/crates/collab_ui/src/chat_panel/message_editor.rs index ee3f5915b2..4f0959b575 100644 --- a/crates/collab_ui/src/chat_panel/message_editor.rs +++ b/crates/collab_ui/src/chat_panel/message_editor.rs @@ -101,7 +101,7 @@ impl MessageEditor { window: &mut Window, cx: &mut Context, ) -> Self { - let this = cx.model().downgrade(); + let this = cx.entity().downgrade(); editor.update(cx, |editor, cx| { editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx); editor.set_use_autoclose(false); diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 555ba426cd..c9eaec4e3b 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -73,7 +73,7 @@ pub fn init(cx: &mut App) { .and_then(|room| room.read(cx).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| { ChannelView::open(channel_id, None, workspace, window, cx) .detach_and_log_err(cx) @@ -239,7 +239,7 @@ impl CollabPanel { ) .detach(); - let model = cx.model().downgrade(); + let model = cx.entity().downgrade(); let list_state = ListState::new( 0, gpui::ListAlignment::Top, @@ -1040,7 +1040,7 @@ impl CollabPanel { window: &mut Window, cx: &mut Context, ) { - let this = cx.model().clone(); + let this = cx.entity().clone(); if !(role == proto::ChannelRole::Guest || role == proto::ChannelRole::Talker || role == proto::ChannelRole::Member) @@ -1170,7 +1170,7 @@ impl CollabPanel { .channel_for_id(clipboard.channel_id) .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| { if self.has_subchannels(ix) { @@ -1337,7 +1337,7 @@ impl CollabPanel { window: &mut Window, cx: &mut Context, ) { - let this = cx.model().clone(); + let this = cx.entity().clone(); let in_room = ActiveCall::global(cx).read(cx).room().is_some(); let context_menu = ContextMenu::build(window, cx, |mut context_menu, _, _| { diff --git a/crates/collab_ui/src/collab_panel/channel_modal.rs b/crates/collab_ui/src/collab_panel/channel_modal.rs index 0568aa7faf..5feb046607 100644 --- a/crates/collab_ui/src/collab_panel/channel_modal.rs +++ b/crates/collab_ui/src/collab_panel/channel_modal.rs @@ -40,7 +40,7 @@ impl ChannelModal { cx: &mut Context, ) -> Self { 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| { Picker::uniform_list( ChannelModalDelegate { @@ -581,7 +581,7 @@ impl ChannelModalDelegate { return; }; 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 role = membership.role; diff --git a/crates/collab_ui/src/collab_panel/contact_finder.rs b/crates/collab_ui/src/collab_panel/contact_finder.rs index ac499c589e..64b2f6f5b2 100644 --- a/crates/collab_ui/src/collab_panel/contact_finder.rs +++ b/crates/collab_ui/src/collab_panel/contact_finder.rs @@ -16,7 +16,7 @@ pub struct ContactFinder { impl ContactFinder { pub fn new(user_store: Entity, window: &mut Window, cx: &mut Context) -> Self { let delegate = ContactFinderDelegate { - parent: cx.model().downgrade(), + parent: cx.entity().downgrade(), user_store, potential_contacts: Arc::from([]), selected_index: 0, diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rs index 4ffb369c53..3b9ba33d6d 100644 --- a/crates/collab_ui/src/notification_panel.rs +++ b/crates/collab_ui/src/notification_panel.rs @@ -110,7 +110,7 @@ impl NotificationPanel { }) .detach(); - let model = cx.model().downgrade(); + let model = cx.entity().downgrade(); let notification_list = ListState::new(0, ListAlignment::Top, px(1000.), move |ix, window, cx| { model @@ -323,7 +323,7 @@ impl NotificationPanel { .justify_end() .child(Button::new("decline", "Decline").on_click({ let notification = notification.clone(); - let model = cx.model().clone(); + let model = cx.entity().clone(); move |_, _, cx| { model.update(cx, |this, cx| { this.respond_to_notification( @@ -336,7 +336,7 @@ impl NotificationPanel { })) .child(Button::new("accept", "Accept").on_click({ let notification = notification.clone(); - let model = cx.model().clone(); + let model = cx.entity().clone(); move |_, _, cx| { model.update(cx, |this, cx| { this.respond_to_notification( @@ -570,7 +570,7 @@ impl NotificationPanel { workspace.dismiss_notification(&id, cx); workspace.show_notification(id, cx, |cx| { - let workspace = cx.model().downgrade(); + let workspace = cx.entity().downgrade(); cx.new(|_| NotificationToast { notification_id, actor, diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index 00a62c5b7c..d4bfe38d56 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -107,7 +107,7 @@ impl CommandPalette { .collect(); 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 = Picker::uniform_list(delegate, window, cx); diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 04dfaa7a89..d9bbb9dae9 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -283,7 +283,7 @@ impl ProjectDiagnosticsEditor { if let Some(existing) = workspace.item_of_type::(cx) { workspace.activate_item(&existing, true, true, window, cx); } else { - let workspace_handle = cx.model().downgrade(); + let workspace_handle = cx.entity().downgrade(); let include_warnings = match cx.try_global::() { Some(include_warnings) => include_warnings.0, diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index f513c20689..5dede72203 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -495,7 +495,7 @@ impl CompletionsMenu { let last_rendered_range = self.last_rendered_range.clone(); let style = style.clone(); let list = uniform_list( - cx.model().clone(), + cx.entity().clone(), "completions", self.entries.borrow().len(), move |_editor, range, _window, cx| { @@ -1090,7 +1090,7 @@ impl CodeActionsMenu { let actions = self.actions.clone(); let selected_item = self.selected_item; let list = uniform_list( - cx.model().clone(), + cx.entity().clone(), "code_actions_menu", self.actions.len(), move |_this, range, _, cx| { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 186c1c2c18..bd5904ccd8 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1159,7 +1159,7 @@ impl Editor { ) -> Self { let style = window.text_style(); 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 { constrain_width: true, render: Arc::new(move |fold_id, fold_range, _, cx| { @@ -15339,7 +15339,7 @@ impl Render for Editor { }; EditorElement::new( - &cx.model(), + &cx.entity(), EditorStyle { background, local_player: cx.theme().players().local(), diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index c0272df52f..94881c10de 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -62,7 +62,7 @@ fn test_edit_events(cx: &mut TestAppContext) { let editor1 = cx.add_window({ let events = events.clone(); |window, cx| { - let model = cx.model().clone(); + let model = cx.entity().clone(); cx.subscribe_in( &model, window, @@ -83,7 +83,7 @@ fn test_edit_events(cx: &mut TestAppContext) { let events = events.clone(); |window, cx| { cx.subscribe_in( - &cx.model().clone(), + &cx.entity().clone(), window, move |_, _, event: &EditorEvent, _, _| match event { EditorEvent::Edited { .. } => events.borrow_mut().push(("editor2", "edited")), @@ -689,7 +689,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) { cx.new(|cx| { let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), 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))); fn pop_history(editor: &mut Editor, cx: &mut App) -> Option { @@ -10180,8 +10180,8 @@ async fn test_following(cx: &mut gpui::TestAppContext) { let is_still_following = Rc::new(RefCell::new(true)); let follower_edit_event_count = Rc::new(RefCell::new(0)); let pending_update = Rc::new(RefCell::new(None)); - let leader_model = leader.root_model(cx).unwrap(); - let follower_model = follower.root_model(cx).unwrap(); + let leader_model = leader.root(cx).unwrap(); + let follower_model = follower.root(cx).unwrap(); _ = follower.update(cx, { let update = pending_update.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. let mut state_message = 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 .update_window(*workspace.deref(), |_, window, cx| { 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. let mut state_message = 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 .update_window(*workspace.deref(), |_, window, cx| { Editor::from_state_proto( @@ -14497,7 +14497,7 @@ fn test_crease_insertion_and_rendering(cx: &mut TestAppContext) { let _div = snapshot.render_crease_toggle( MultiBufferRow(1), false, - cx.model().clone(), + cx.entity().clone(), window, 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" ); assert_eq!( - test_editor_cx.model(), + test_editor_cx.entity(), 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 .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") .read(test_editor_cx) .text(test_editor_cx); diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index f0eb761612..272243fd6f 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -6246,7 +6246,7 @@ impl Element for EditorElement { let height = self.style.text.line_height_in_pixels(rem_size); if auto_width { - let editor_handle = cx.model().clone(); + let editor_handle = cx.entity().clone(); let style = self.style.clone(); window.request_measured_layout( Style::default(), @@ -6287,7 +6287,7 @@ impl Element for EditorElement { } } EditorMode::AutoHeight { max_lines } => { - let editor_handle = cx.model().clone(); + let editor_handle = cx.entity().clone(); let max_line_number_width = self.max_line_number_width(&editor.snapshot(window, cx), window, cx); window.request_measured_layout( diff --git a/crates/editor/src/git/project_diff.rs b/crates/editor/src/git/project_diff.rs index 6a732af055..6bc12c1782 100644 --- a/crates/editor/src/git/project_diff.rs +++ b/crates/editor/src/git/project_diff.rs @@ -77,7 +77,7 @@ impl ProjectDiffEditor { if let Some(existing) = workspace.item_of_type::(cx) { workspace.activate_item(&existing, true, true, window, cx); } else { - let workspace_handle = cx.model().downgrade(); + let workspace_handle = cx.entity().downgrade(); let project_diff = 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); diff --git a/crates/editor/src/hunk_diff.rs b/crates/editor/src/hunk_diff.rs index 96f32c8187..d6e6be1c86 100644 --- a/crates/editor/src/hunk_diff.rs +++ b/crates/editor/src/hunk_diff.rs @@ -596,7 +596,7 @@ impl Editor { style: BlockStyle::Sticky, priority: 0, render: Arc::new({ - let editor = cx.model().clone(); + let editor = cx.entity().clone(); let hunk = hunk.clone(); let has_multiple_hunks = self.has_multiple_hunks(cx); @@ -870,7 +870,7 @@ impl Editor { let deleted_hunk_color = deleted_hunk_color(cx); let (editor_height, editor_with_deleted_text) = 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 height = editor_height.max(deleted_text_height); BlockProperties { @@ -1214,7 +1214,7 @@ fn editor_with_deleted_text( window: &mut Window, cx: &mut Context, ) -> (u32, Model) { - let parent_editor = cx.model().downgrade(); + let parent_editor = cx.entity().downgrade(); let editor = cx.new(|cx| { let multi_buffer = cx.new(|_| MultiBuffer::without_headers(language::Capability::ReadOnly)); multi_buffer.update(cx, |multi_buffer, cx| { diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rs index 2b348b7e74..0b2c581926 100644 --- a/crates/editor/src/scroll.rs +++ b/crates/editor/src/scroll.rs @@ -317,7 +317,7 @@ impl ScrollManager { self.show_scrollbar(window, cx); self.autoscroll_request.take(); 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() .spawn(async move { diff --git a/crates/editor/src/test/editor_lsp_test_context.rs b/crates/editor/src/test/editor_lsp_test_context.rs index d35487f00f..a0357b9ded 100644 --- a/crates/editor/src/test/editor_lsp_test_context.rs +++ b/crates/editor/src/test/editor_lsp_test_context.rs @@ -133,7 +133,7 @@ impl EditorLspTestContext { 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); project diff --git a/crates/editor/src/test/editor_test_context.rs b/crates/editor/src/test/editor_test_context.rs index 8e9ce83165..a4e6013400 100644 --- a/crates/editor/src/test/editor_test_context.rs +++ b/crates/editor/src/test/editor_test_context.rs @@ -67,7 +67,7 @@ impl EditorTestContext { window.focus(&editor.focus_handle(cx)); editor }); - let editor_view = editor.root_model(cx).unwrap(); + let editor_view = editor.root(cx).unwrap(); cx.run_until_parked(); Self { @@ -89,7 +89,7 @@ impl EditorTestContext { } pub async fn for_editor(editor: WindowHandle, cx: &mut gpui::TestAppContext) -> Self { - let editor_view = editor.root_model(cx).unwrap(); + let editor_view = editor.root(cx).unwrap(); Self { cx: VisualTestContext::from_window(*editor.deref(), cx), window: editor.into(), @@ -126,7 +126,7 @@ impl EditorTestContext { editor }); - let editor_view = editor.root_model(cx).unwrap(); + let editor_view = editor.root(cx).unwrap(); Self { cx: VisualTestContext::from_window(*editor.deref(), cx), window: editor.into(), diff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rs index 74037a6b2c..e1acd70249 100644 --- a/crates/extensions_ui/src/extensions_ui.rs +++ b/crates/extensions_ui/src/extensions_ui.rs @@ -74,7 +74,7 @@ pub fn init(cx: &mut App) { cx, ); - let workspace_handle = cx.model().downgrade(); + let workspace_handle = cx.entity().downgrade(); window .spawn(cx, |mut cx| async move { let extension_path = @@ -533,7 +533,7 @@ impl ExtensionsPage { extension: &ExtensionMetadata, cx: &mut Context, ) -> ExtensionCard { - let this = cx.model().clone(); + let this = cx.entity().clone(); let status = Self::extension_status(&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| { let delegate = ExtensionVersionSelectorDelegate::new( fs, - cx.model().downgrade(), + cx.entity().downgrade(), extension_versions, ); @@ -1160,7 +1160,7 @@ impl Render for ExtensionsPage { 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(); this.child( uniform_list(extensions_page, "entries", count, Self::render_extensions) diff --git a/crates/feedback/src/feedback_modal.rs b/crates/feedback/src/feedback_modal.rs index 74a2968441..0e56cd1952 100644 --- a/crates/feedback/src/feedback_modal.rs +++ b/crates/feedback/src/feedback_modal.rs @@ -132,7 +132,7 @@ impl ModalView for FeedbackModal { impl FeedbackModal { pub fn register(workspace: &mut Workspace, _: &mut Window, cx: &mut Context) { - let _handle = cx.model().downgrade(); + let _handle = cx.entity().downgrade(); workspace.register_action(move |workspace, _: &GiveFeedback, window, cx| { workspace .with_local_workspace(window, cx, |workspace, window, cx| { diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 3938641f20..c4a4362600 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -147,10 +147,10 @@ impl FileFinder { workspace .update_in(&mut cx, |workspace, window, cx| { let project = workspace.project().clone(); - let weak_workspace = cx.model().downgrade(); + let weak_workspace = cx.entity().downgrade(); workspace.toggle_modal(window, cx, |window, cx| { let delegate = FileFinderDelegate::new( - cx.model().downgrade(), + cx.entity().downgrade(), weak_workspace, project, currently_opened_path, diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 88cd0d1ce6..a7d65b0cbb 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -156,7 +156,7 @@ impl GitPanel { let git_state = project.read(cx).git_state().cloned(); let active_repository = project.read(cx).active_repository(cx); 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 focus_handle = cx.focus_handle(); @@ -193,7 +193,7 @@ impl GitPanel { current_modifiers: window.modifiers(), width: Some(px(360.)), scrollbar_state: ScrollbarState::new(scroll_handle.clone()) - .parent_model(&cx.model()), + .parent_model(&cx.entity()), selected_entry: None, show_scrollbar: false, hide_scrollbar_task: None, @@ -703,7 +703,7 @@ impl GitPanel { } fn schedule_update(&mut self, window: &mut Window, cx: &mut Context) { - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); self.update_visible_entries_task = cx.spawn_in(window, |_, mut cx| async move { cx.background_executor().timer(UPDATE_DEBOUNCE).await; if let Some(this) = handle.upgrade() { @@ -1114,7 +1114,7 @@ impl GitPanel { .size_full() .overflow_hidden() .child( - uniform_list(cx.model().clone(), "entries", entry_count, { + uniform_list(cx.entity().clone(), "entries", entry_count, { move |git_panel, range, _window, cx| { let mut items = Vec::with_capacity(range.end - range.start); git_panel.for_each_visible_entry(range, cx, |ix, details, cx| { @@ -1167,7 +1167,7 @@ impl GitPanel { let checkbox_id = ElementId::Name(format!("checkbox_{}", entry_details.display_name).into()); let is_tree_view = false; - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); let end_slot = h_flex() .invisible() diff --git a/crates/git_ui/src/repository_selector.rs b/crates/git_ui/src/repository_selector.rs index 62b264c5eb..8c02c66218 100644 --- a/crates/git_ui/src/repository_selector.rs +++ b/crates/git_ui/src/repository_selector.rs @@ -27,7 +27,7 @@ impl RepositorySelector { let filtered_repositories = all_repositories.clone(); let delegate = RepositorySelectorDelegate { project: project.downgrade(), - repository_selector: cx.model().downgrade(), + repository_selector: cx.entity().downgrade(), repository_entries: all_repositories, filtered_repositories, selected_index: 0, diff --git a/crates/go_to_line/src/go_to_line.rs b/crates/go_to_line/src/go_to_line.rs index 1a8820c049..7defe355be 100644 --- a/crates/go_to_line/src/go_to_line.rs +++ b/crates/go_to_line/src/go_to_line.rs @@ -42,7 +42,7 @@ enum GoToLineRowHighlights {} impl GoToLine { fn register(editor: &mut Editor, _window: Option<&mut Window>, cx: &mut Context) { - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); editor .register_action(move |_: &editor::actions::ToggleGoToLine, window, cx| { let Some(editor_handle) = handle.upgrade() else { @@ -94,7 +94,7 @@ impl GoToLine { let line_editor = cx.new(|cx| { let mut editor = Editor::single_line(window, cx); - let editor_handle = cx.model().downgrade(); + let editor_handle = cx.entity().downgrade(); editor .register_action::({ move |_, window, cx| { diff --git a/crates/gpui/examples/input.rs b/crates/gpui/examples/input.rs index 286160d699..bef1546f06 100644 --- a/crates/gpui/examples/input.rs +++ b/crates/gpui/examples/input.rs @@ -572,7 +572,7 @@ impl Render for TextInput { .p(px(4.)) .bg(white()) .child(TextElement { - input: cx.model().clone(), + input: cx.entity().clone(), }), ) } @@ -697,7 +697,7 @@ fn main() { }, ) .unwrap(); - let view = window.root_model(cx).unwrap(); + let view = window.root(cx).unwrap(); cx.observe_keystrokes(move |ev, _, cx| { view.update(cx, |view, cx| { view.recent_keystrokes.push(ev.keystroke.clone()); diff --git a/crates/gpui/examples/uniform_list.rs b/crates/gpui/examples/uniform_list.rs index 60158c4ce7..00a98182c3 100644 --- a/crates/gpui/examples/uniform_list.rs +++ b/crates/gpui/examples/uniform_list.rs @@ -9,7 +9,7 @@ impl Render for UniformListExample { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { div().size_full().bg(rgb(0xffffff)).child( uniform_list( - cx.model().clone(), + cx.entity().clone(), "entries", 50, |_this, range, _window, _cx| { diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 715f58756d..5546178eac 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -603,7 +603,7 @@ impl App { cx.window_update_stack.push(id); let root_view = build_root_view(&mut window, cx); 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)); cx.window_handles.insert(id, window.handle); cx.windows.get_mut(id).unwrap().replace(window); @@ -999,7 +999,7 @@ impl App { .take() .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); let result = update(root_view, &mut window, cx); @@ -1666,7 +1666,7 @@ impl AppContext for App { .as_ref() .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 .downcast::() .map_err(|_| anyhow!("root view's type has changed"))?; diff --git a/crates/gpui/src/app/async_context.rs b/crates/gpui/src/app/async_context.rs index f1640a58f5..567a4c5ae5 100644 --- a/crates/gpui/src/app/async_context.rs +++ b/crates/gpui/src/app/async_context.rs @@ -399,9 +399,8 @@ impl VisualContext for AsyncWindowContext { where V: 'static + Render, { - self.window.update(self, |_, window, cx| { - window.replace_root_model(cx, build_view) - }) + self.window + .update(self, |_, window, cx| window.replace_root(cx, build_view)) } fn focus(&mut self, view: &Entity) -> Self::Result<()> diff --git a/crates/gpui/src/app/model_context.rs b/crates/gpui/src/app/model_context.rs index 64ebcd3693..daac8c506d 100644 --- a/crates/gpui/src/app/model_context.rs +++ b/crates/gpui/src/app/model_context.rs @@ -35,14 +35,14 @@ impl<'a, T: 'static> Context<'a, T> { } /// Returns a handle to the model belonging to this context. - pub fn model(&self) -> Entity { - self.weak_model() + pub fn entity(&self) -> Entity { + self.weak_entity() .upgrade() .expect("The entity must be alive if we have a model context") } /// Returns a weak handle to the model belonging to this context. - pub fn weak_model(&self) -> WeakEntity { + pub fn weak_entity(&self) -> WeakEntity { self.model_state.clone() } @@ -57,7 +57,7 @@ impl<'a, T: 'static> Context<'a, T> { T: 'static, W: 'static, { - let this = self.weak_model(); + let this = self.weak_entity(); self.app.observe_internal(entity, move |e, cx| { if let Some(this) = this.upgrade() { 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: 'static, { - let this = self.weak_model(); + let this = self.weak_entity(); self.app.subscribe_internal(entity, move |e, event, cx| { if let Some(this) = this.upgrade() { this.update(cx, |this, cx| on_event(this, e, event, cx)); @@ -117,7 +117,7 @@ impl<'a, T: 'static> Context<'a, T> { T2: 'static, { let entity_id = entity.entity_id(); - let this = self.weak_model(); + let this = self.weak_entity(); let (subscription, activate) = self.app.release_listeners.insert( entity_id, Box::new(move |entity, cx| { @@ -139,7 +139,7 @@ impl<'a, T: 'static> Context<'a, T> { where T: 'static, { - let handle = self.weak_model(); + let handle = self.weak_entity(); let (subscription, activate) = self.global_observers.insert( TypeId::of::(), 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, T: 'static, { - let handle = self.weak_model(); + let handle = self.weak_entity(); let (subscription, activate) = self.app.quit_observers.insert( (), Box::new(move |cx| { @@ -189,7 +189,7 @@ impl<'a, T: 'static> Context<'a, T> { Fut: Future + 'static, R: 'static, { - let this = self.weak_model(); + let this = self.weak_entity(); self.app.spawn(|cx| f(this, cx)) } @@ -202,7 +202,7 @@ impl<'a, T: 'static> Context<'a, T> { &self, f: impl Fn(&mut T, &E, &mut Window, &mut Context) + '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| { view.update(cx, |view, cx| f(view, e, window, cx)).ok(); } @@ -221,7 +221,7 @@ impl<'a, T: 'static> Context<'a, T> { ) where 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))); } @@ -232,7 +232,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &Window, f: impl FnOnce(&mut T, &mut Window, &mut Context) + 'static, ) { - let view = self.model(); + let view = self.entity(); window.defer(self, move |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 = observed.downgrade(); let window_handle = window.handle; - let observer = self.weak_model(); + let observer = self.weak_entity(); self.new_observer( observed_id, Box::new(move |cx| { @@ -290,7 +290,7 @@ impl<'a, T: 'static> Context<'a, T> { { let emitter = emitter.downgrade(); let window_handle = window.handle; - let subscriber = self.weak_model(); + let subscriber = self.weak_entity(); self.new_subscription( emitter.entity_id(), ( @@ -348,7 +348,7 @@ impl<'a, T: 'static> Context<'a, T> { T: 'static, V2: 'static, { - let observer = self.weak_model(); + let observer = self.weak_entity(); let window_handle = window.handle; let (subscription, activate) = self.release_listeners.insert( observed.entity_id(), @@ -371,7 +371,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut callback: impl FnMut(&mut T, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let (subscription, activate) = window.bounds_observers.insert( (), Box::new(move |window, cx| { @@ -389,7 +389,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut callback: impl FnMut(&mut T, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let (subscription, activate) = window.activation_observers.insert( (), Box::new(move |window, cx| { @@ -407,7 +407,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut callback: impl FnMut(&mut T, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let (subscription, activate) = window.appearance_observers.insert( (), Box::new(move |window, cx| { @@ -435,7 +435,7 @@ impl<'a, T: 'static> Context<'a, T> { subscription } - let view = self.weak_model(); + let view = self.weak_entity(); inner( &mut self.keystroke_observers, Box::new(move |event, window, cx| { @@ -455,7 +455,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut callback: impl FnMut(&mut T, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let (subscription, activate) = window.pending_input_observers.insert( (), Box::new(move |window, cx| { @@ -475,7 +475,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut listener: impl FnMut(&mut T, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let focus_id = handle.id; let (subscription, activate) = window.new_focus_listener(Box::new(move |event, window, cx| { @@ -501,7 +501,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut listener: impl FnMut(&mut T, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let focus_id = handle.id; let (subscription, activate) = window.new_focus_listener(Box::new(move |event, window, cx| { @@ -524,7 +524,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut listener: impl FnMut(&mut T, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let focus_id = handle.id; let (subscription, activate) = window.new_focus_listener(Box::new(move |event, window, cx| { @@ -550,7 +550,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut listener: impl FnMut(&mut T, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let (subscription, activate) = window.focus_lost_listeners.insert( (), Box::new(move |window, cx| { @@ -570,7 +570,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, mut listener: impl FnMut(&mut T, FocusOutEvent, &mut Window, &mut Context) + 'static, ) -> Subscription { - let view = self.weak_model(); + let view = self.weak_entity(); let focus_id = handle.id; let (subscription, activate) = window.new_focus_listener(Box::new(move |event, window, cx| { @@ -606,7 +606,7 @@ impl<'a, T: 'static> Context<'a, T> { R: 'static, Fut: Future + 'static, { - let view = self.weak_model(); + let view = self.weak_entity(); 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, ) -> Subscription { let window_handle = window.handle; - let view = self.weak_model(); + let view = self.weak_entity(); let (subscription, activate) = self.global_observers.insert( TypeId::of::(), Box::new(move |cx| { @@ -639,7 +639,7 @@ impl<'a, T: 'static> Context<'a, T> { window: &mut Window, listener: impl Fn(&mut T, &dyn Any, DispatchPhase, &mut Window, &mut Context) + 'static, ) { - let handle = self.weak_model(); + let handle = self.weak_entity(); window.on_action(action_type, move |action, phase, window, cx| { handle .update(cx, |view, cx| { @@ -654,7 +654,7 @@ impl<'a, T: 'static> Context<'a, T> { where T: Focusable, { - let view = self.model(); + let view = self.entity(); window.defer(self, move |window, cx| { view.read(cx).focus_handle(cx).focus(window) }) diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rs index 0366ad27e9..86a3e49034 100644 --- a/crates/gpui/src/app/test_context.rs +++ b/crates/gpui/src/app/test_context.rs @@ -238,7 +238,7 @@ impl TestAppContext { ) .unwrap(); 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(); cx.run_until_parked(); @@ -946,7 +946,7 @@ impl VisualContext for VisualTestContext { { self.window .update(&mut self.cx, |_, window, cx| { - window.replace_root_model(cx, build_view) + window.replace_root(cx, build_view) }) .unwrap() } diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 81002f6d36..da7483fd51 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -609,7 +609,7 @@ pub struct Window { rem_size_override_stack: SmallVec<[Pixels; 8]>, pub(crate) viewport_size: Size, layout_engine: Option, - pub(crate) root_model: Option, + pub(crate) root: Option, pub(crate) element_id_stack: SmallVec<[ElementId; 32]>, pub(crate) text_style_stack: Vec, pub(crate) element_offset_stack: Vec>, @@ -887,7 +887,7 @@ impl Window { rem_size_override_stack: SmallVec::new(), viewport_size: content_size, layout_engine: Some(TaffyLayoutEngine::new()), - root_model: None, + root: None, element_id_stack: SmallVec::default(), text_style_stack: Vec::new(), element_offset_stack: Vec::new(), @@ -1019,27 +1019,27 @@ impl Window { subscription } - pub fn replace_root_model( + pub fn replace_root( &mut self, cx: &mut App, - build_view: impl FnOnce(&mut Window, &mut Context<'_, V>) -> V, - ) -> Entity + build_view: impl FnOnce(&mut Window, &mut Context<'_, E>) -> E, + ) -> Entity where - V: 'static + Render, + E: 'static + Render, { let view = cx.new(|cx| build_view(self, cx)); - self.root_model = Some(view.clone().into()); + self.root = Some(view.clone().into()); self.refresh(); view } - pub fn root_model(&mut self) -> Option>> + pub fn root(&self) -> Option>> where - V: 'static + Render, + E: 'static + Render, { - self.root_model + self.root .as_ref() - .map(|view| view.clone().downcast::().ok()) + .map(|view| view.clone().downcast::().ok()) } /// Obtain a handle to the window that belongs to this context. @@ -1632,7 +1632,7 @@ impl Window { self.tooltip_bounds.take(); // 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); let mut sorted_deferred_draws = @@ -3816,7 +3816,7 @@ impl WindowHandle { .and_then(|window| { window .as_ref() - .and_then(|window| window.root_model.clone()) + .and_then(|window| window.root.clone()) .map(|root_view| root_view.downcast::()) }) .ok_or_else(|| anyhow!("window not found"))? @@ -3838,7 +3838,7 @@ impl WindowHandle { /// 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`. - pub fn root_model(&self, cx: &C) -> Result> + pub fn entity(&self, cx: &C) -> Result> where C: AppContext, { diff --git a/crates/inline_completion_button/src/inline_completion_button.rs b/crates/inline_completion_button/src/inline_completion_button.rs index 05e6b0b1b2..5937265250 100644 --- a/crates/inline_completion_button/src/inline_completion_button.rs +++ b/crates/inline_completion_button/src/inline_completion_button.rs @@ -121,7 +121,7 @@ impl Render for InlineCompletionButton { }), ); } - let this = cx.model().clone(); + let this = cx.entity().clone(); div().child( PopoverMenu::new("copilot") @@ -173,7 +173,7 @@ impl Render for InlineCompletionButton { let icon = status.to_icon(); let tooltip_text = status.to_tooltip(); let has_menu = status.has_menu(); - let this = cx.model().clone(); + let this = cx.entity().clone(); let fs = self.fs.clone(); 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( !self.popover_menu_handle.is_deployed(), |button| { @@ -399,7 +399,7 @@ impl InlineCompletionButton { None, move |window, cx| { if let Some(workspace) = window.window_handle().downcast::() { - if let Ok(workspace) = workspace.root_model(cx) { + if let Ok(workspace) = workspace.root(cx) { let workspace = workspace.downgrade(); window .spawn(cx, |cx| { diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 0e4831a6bf..c43736d982 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -972,7 +972,7 @@ impl Buffer { } pub fn branch(&mut self, cx: &mut Context) -> Entity { - let this = cx.model(); + let this = cx.entity(); cx.new(|cx| { let mut branch = Self { branch_state: Some(BufferBranchState { diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rs index e2ac3a55ab..59e5e44f2c 100644 --- a/crates/language/src/buffer_tests.rs +++ b/crates/language/src/buffer_tests.rs @@ -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))); let network = network.clone(); - cx.subscribe(&cx.model(), move |buffer, _, event, _| { + cx.subscribe(&cx.entity(), move |buffer, _, event, _| { if let BufferEvent::Operation { operation, 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))); let network = network.clone(); - cx.subscribe(&cx.model(), move |buffer, _, event, _| { + cx.subscribe(&cx.entity(), move |buffer, _, event, _| { if let BufferEvent::Operation { operation, is_local: true, diff --git a/crates/language_model_selector/src/language_model_selector.rs b/crates/language_model_selector/src/language_model_selector.rs index f70797f19e..b6f172cfc1 100644 --- a/crates/language_model_selector/src/language_model_selector.rs +++ b/crates/language_model_selector/src/language_model_selector.rs @@ -33,7 +33,7 @@ impl LanguageModelSelector { let all_models = Self::all_models(cx); let delegate = LanguageModelPickerDelegate { - language_model_selector: cx.model().downgrade(), + language_model_selector: cx.entity().downgrade(), on_model_changed: on_model_changed.clone(), all_models: all_models.clone(), filtered_models: all_models, diff --git a/crates/language_models/src/provider/cloud.rs b/crates/language_models/src/provider/cloud.rs index e9e3c7539e..27d0e12596 100644 --- a/crates/language_models/src/provider/cloud.rs +++ b/crates/language_models/src/provider/cloud.rs @@ -124,7 +124,7 @@ impl RefreshLlmTokenListener { fn new(client: Arc, cx: &mut Context) -> Self { Self { _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), } } diff --git a/crates/language_selector/src/language_selector.rs b/crates/language_selector/src/language_selector.rs index 0f1d3a8818..6b28ce185b 100644 --- a/crates/language_selector/src/language_selector.rs +++ b/crates/language_selector/src/language_selector.rs @@ -67,7 +67,7 @@ impl LanguageSelector { cx: &mut Context, ) -> Self { let delegate = LanguageSelectorDelegate::new( - cx.model().downgrade(), + cx.entity().downgrade(), buffer, project, language_registry, diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs index 0e48730f13..1ab9ea079b 100644 --- a/crates/language_tools/src/lsp_log.rs +++ b/crates/language_tools/src/lsp_log.rs @@ -242,7 +242,7 @@ impl LogStore { if let copilot::Event::CopilotLanguageServerStarted = inline_completion_event { if let Some(server) = copilot.read(cx).language_server() { let server_id = server.server_id(); - let weak_this = cx.weak_model(); + let weak_this = cx.weak_entity(); this.copilot_log_subscription = Some(server.on_notification::( move |params, mut cx| { @@ -926,7 +926,7 @@ impl LspLogView { .expect("log buffer should be a singleton") .update(cx, |_, cx| { cx.spawn({ - let buffer = cx.model(); + let buffer = cx.entity(); |_, mut cx| async move { let language = language.await.ok(); buffer.update(&mut cx, |buffer, cx| { @@ -1222,7 +1222,7 @@ impl Render for LspLogToolbarItemView { ) }) .collect(); - let log_toolbar_view = cx.model().clone(); + let log_toolbar_view = cx.entity().clone(); let lsp_menu = PopoverMenu::new("LspLogView") .anchor(Corner::TopLeft) .trigger(Button::new( diff --git a/crates/language_tools/src/syntax_tree_view.rs b/crates/language_tools/src/syntax_tree_view.rs index 4d02ecd31d..4f4579b0a0 100644 --- a/crates/language_tools/src/syntax_tree_view.rs +++ b/crates/language_tools/src/syntax_tree_view.rs @@ -303,7 +303,7 @@ impl Render for SyntaxTreeView { { let layer = layer.clone(); rendered = rendered.child(uniform_list( - cx.model().clone(), + cx.entity().clone(), "SyntaxTreeView", layer.node().descendant_count(), move |this, range, _, cx| { @@ -451,7 +451,7 @@ impl SyntaxTreeToolbarItemView { let active_layer = buffer_state.active_layer.clone()?; let active_buffer = buffer_state.buffer.read(cx).snapshot(); - let view = cx.model().clone(); + let view = cx.entity().clone(); Some( PopoverMenu::new("Syntax Tree") .trigger(Self::render_header(&active_layer)) diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 9ae8b482c5..5112a68063 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -219,7 +219,7 @@ impl Markdown { impl Render for Markdown { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { MarkdownElement::new( - cx.model().clone(), + cx.entity().clone(), self.style.clone(), self.language_registry.clone(), self.fallback_code_block_language.clone(), diff --git a/crates/markdown_preview/src/markdown_preview_view.rs b/crates/markdown_preview/src/markdown_preview_view.rs index bbb09f1986..886a0b4d26 100644 --- a/crates/markdown_preview/src/markdown_preview_view.rs +++ b/crates/markdown_preview/src/markdown_preview_view.rs @@ -144,7 +144,7 @@ impl MarkdownPreviewView { cx: &mut Context, ) -> Entity { cx.new(|cx| { - let view = cx.model().downgrade(); + let view = cx.entity().downgrade(); let list_state = ListState::new( 0, diff --git a/crates/notifications/src/notification_store.rs b/crates/notifications/src/notification_store.rs index b943e24538..d8037a02f9 100644 --- a/crates/notifications/src/notification_store.rs +++ b/crates/notifications/src/notification_store.rs @@ -103,9 +103,9 @@ impl NotificationStore { channel_messages: Default::default(), _watch_connection_status: watch_connection_status, _subscriptions: vec![ - client.add_message_handler(cx.weak_model(), Self::handle_new_notification), - client.add_message_handler(cx.weak_model(), Self::handle_delete_notification), - client.add_message_handler(cx.weak_model(), Self::handle_update_notification), + client.add_message_handler(cx.weak_entity(), Self::handle_new_notification), + client.add_message_handler(cx.weak_entity(), Self::handle_delete_notification), + client.add_message_handler(cx.weak_entity(), Self::handle_update_notification), ], user_store, client, diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index 1ff40532a6..d44cc94796 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -88,7 +88,7 @@ impl Render for OutlineView { impl OutlineView { fn register(editor: &mut Editor, _: Option<&mut Window>, cx: &mut Context) { if editor.mode() == EditorMode::Full { - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); editor .register_action(move |action, window, cx| { if let Some(editor) = handle.upgrade() { @@ -105,7 +105,7 @@ impl OutlineView { window: &mut Window, cx: &mut Context, ) -> 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| { Picker::uniform_list(delegate, window, cx).max_height(Some(vh(0.75, window))) }); diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 3830da39cb..8f99fe198d 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -709,7 +709,7 @@ impl OutlinePanel { cx: &mut Context, ) -> Entity { let project = workspace.project().clone(); - let workspace_handle = cx.model().downgrade(); + let workspace_handle = cx.entity().downgrade(); let outline_panel = cx.new(|cx| { let filter_editor = cx.new(|cx| { let mut editor = Editor::single_line(window, cx); @@ -796,9 +796,9 @@ impl OutlinePanel { show_scrollbar: !Self::should_autohide_scrollbar(cx), hide_scrollbar_task: None, vertical_scrollbar_state: ScrollbarState::new(scroll_handle.clone()) - .parent_model(&cx.model()), + .parent_model(&cx.entity()), horizontal_scrollbar_state: ScrollbarState::new(scroll_handle.clone()) - .parent_model(&cx.model()), + .parent_model(&cx.entity()), max_width_item_index: None, scroll_handle, focus_handle, @@ -4467,7 +4467,7 @@ impl OutlinePanel { let multi_buffer_snapshot = self .active_editor() .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| { let entries = outline_panel.cached_entries.get(range); entries @@ -4534,7 +4534,7 @@ impl OutlinePanel { .when(show_indent_guides, |list| { list.with_decoration( ui::indent_guides( - cx.model().clone(), + cx.entity().clone(), px(indent_size), IndentGuideColors::panel(cx), |outline_panel, range, _, _| { @@ -4547,7 +4547,7 @@ impl OutlinePanel { }, ) .with_render_fn( - cx.model().clone(), + cx.entity().clone(), move |outline_panel, params, _, _| { const LEFT_OFFSET: f32 = 14.; diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index bad7b18970..f26bda81ec 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -281,7 +281,7 @@ impl Picker { ElementContainer::UniformList(UniformListScrollHandle::new()) } ContainerKind::List => { - let model = cx.model().downgrade(); + let model = cx.entity().downgrade(); ElementContainer::List(ListState::new( 0, gpui::ListAlignment::Top, @@ -643,7 +643,7 @@ impl Picker { }; match &self.element_container { ElementContainer::UniformList(scroll_handle) => uniform_list( - cx.model().clone(), + cx.entity().clone(), "candidates", self.delegate.match_count(), move |picker, visible_range, window, cx| { diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index a157a33277..e10bfa33ce 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -687,7 +687,7 @@ impl LocalBufferStore { buffer_id, ); events.push(BufferStoreEvent::BufferChangedFilePath { - buffer: cx.model(), + buffer: cx.entity(), old_file: buffer.file().cloned(), }); } @@ -875,7 +875,7 @@ impl LocalBufferStore { if !push_to_history { 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, }; - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); buffer.update(cx, move |_, cx| { cx.on_release(move |buffer, cx| { handle diff --git a/crates/project/src/connection_manager.rs b/crates/project/src/connection_manager.rs index c952d4678d..b3784acf62 100644 --- a/crates/project/src/connection_manager.rs +++ b/crates/project/src/connection_manager.rs @@ -39,7 +39,7 @@ impl Manager { project: &Entity, cx: &mut Context, ) { - let manager = cx.weak_model(); + let manager = cx.weak_entity(); project.update(cx, |_, cx| { let manager = manager.clone(); cx.on_release(move |project, cx| { diff --git a/crates/project/src/git.rs b/crates/project/src/git.rs index 8fbdb3d52c..b1b47808d8 100644 --- a/crates/project/src/git.rs +++ b/crates/project/src/git.rs @@ -122,7 +122,7 @@ impl GitState { let mut new_repositories = Vec::new(); let mut new_active_index = None; - let this = cx.weak_model(); + let this = cx.weak_entity(); worktree_store.update(cx, |worktree_store, cx| { for worktree in worktree_store.worktrees() { diff --git a/crates/project/src/image_store.rs b/crates/project/src/image_store.rs index 31500890a7..1b5d47da76 100644 --- a/crates/project/src/image_store.rs +++ b/crates/project/src/image_store.rs @@ -203,7 +203,7 @@ pub struct ImageStore { impl ImageStore { pub fn local(worktree_store: Entity, cx: &mut Context) -> Self { - let this = cx.weak_model(); + let this = cx.weak_entity(); Self { state: Box::new(cx.new(|cx| { let subscription = cx.subscribe( diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index a16a809556..63620ab1c9 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -417,7 +417,7 @@ impl LocalLspStore { let delegate = LocalLspAdapterDelegate::new( self.languages.clone(), &self.environment, - cx.weak_model(), + cx.weak_entity(), &worktree, self.http_client.clone(), self.fs.clone(), @@ -5153,7 +5153,7 @@ impl LspStore { let delegate = LocalLspAdapterDelegate::new( local.languages.clone(), &local.environment, - cx.weak_model(), + cx.weak_entity(), &worktree, local.http_client.clone(), local.fs.clone(), @@ -8159,7 +8159,7 @@ impl LanguageServerWatchedPathsBuilder { language_server_id: LanguageServerId, cx: &mut Context, ) -> LanguageServerWatchedPaths { - let project = cx.weak_model(); + let project = cx.weak_entity(); const LSP_ABS_PATH_OBSERVE: Duration = Duration::from_millis(100); let abs_paths = self diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index c259294fa9..32d21b2814 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -869,7 +869,7 @@ impl Project { }; 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.worktree_store); ssh.subscribe_to_entity(SSH_PROJECT_ID, &this.lsp_store); @@ -1585,7 +1585,7 @@ impl Project { self.client_subscriptions.extend([ self.client .subscribe_to_entity(project_id)? - .set_model(&cx.model(), &mut cx.to_async()), + .set_model(&cx.entity(), &mut cx.to_async()), self.client .subscribe_to_entity(project_id)? .set_model(&self.worktree_store, &mut cx.to_async()), @@ -2427,7 +2427,7 @@ impl Project { delay } else { if first_insertion { - let this = cx.weak_model(); + let this = cx.weak_entity(); cx.defer(move |cx| { if let Some(this) = this.upgrade() { this.update(cx, |this, cx| { diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 8b3ea190e4..c8f34381cb 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -401,9 +401,9 @@ impl ProjectPanel { show_scrollbar: !Self::should_autohide_scrollbar(cx), hide_scrollbar_task: None, vertical_scrollbar_state: ScrollbarState::new(scroll_handle.clone()) - .parent_model(&cx.model()), + .parent_model(&cx.entity()), horizontal_scrollbar_state: ScrollbarState::new(scroll_handle.clone()) - .parent_model(&cx.model()), + .parent_model(&cx.entity()), max_width_item_index: None, diagnostics: Default::default(), scroll_handle, @@ -4227,7 +4227,7 @@ impl Render for ProjectPanel { ) .track_focus(&self.focus_handle(cx)) .child( - uniform_list(cx.model().clone(), "entries", item_count, { + uniform_list(cx.entity().clone(), "entries", item_count, { |this, range, window, cx| { let mut items = Vec::with_capacity(range.end - range.start); this.for_each_visible_entry( @@ -4244,7 +4244,7 @@ impl Render for ProjectPanel { .when(show_indent_guides, |list| { list.with_decoration( ui::indent_guides( - cx.model().clone(), + cx.entity().clone(), px(indent_size), IndentGuideColors::panel(cx), |this, range, window, cx| { @@ -4287,7 +4287,7 @@ impl Render for ProjectPanel { }, )) .with_render_fn( - cx.model().clone(), + cx.entity().clone(), move |this, params, _, cx| { const LEFT_OFFSET: f32 = 14.; const PADDING_Y: f32 = 4.; diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index 0a07141c5a..2b2462ef25 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -21,7 +21,7 @@ pub fn init(cx: &mut App) { workspace.register_action( |workspace, _: &workspace::ToggleProjectSymbols, window, cx| { let project = workspace.project().clone(); - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); workspace.toggle_modal(window, cx, move |window, cx| { let delegate = ProjectSymbolsDelegate::new(handle, project); Picker::uniform_list(delegate, window, cx).width(rems(34.)) diff --git a/crates/recent_projects/src/disconnected_overlay.rs b/crates/recent_projects/src/disconnected_overlay.rs index d8c50c389f..ecc303fc19 100644 --- a/crates/recent_projects/src/disconnected_overlay.rs +++ b/crates/recent_projects/src/disconnected_overlay.rs @@ -64,7 +64,7 @@ impl DisconnectedOverlay { ) { return; } - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); let ssh_connection_options = project.read(cx).ssh_connection_options(cx); let host = if let Some(ssh_connection_options) = ssh_connection_options { diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index 823e8e8178..28b5756619 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -109,7 +109,7 @@ impl RecentProjects { window: &mut Window, cx: &mut Context, ) { - let weak = cx.model().downgrade(); + let weak = cx.entity().downgrade(); workspace.toggle_modal(window, cx, |window, cx| { let delegate = RecentProjectsDelegate::new(weak, create_new_window, true); diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index 7f0297f7f4..418a7844ee 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -145,7 +145,7 @@ impl ProjectPicker { let Ok(Some(paths)) = rx.await else { workspace .update_in(&mut cx, |workspace, window, cx| { - let weak = cx.model().downgrade(); + let weak = cx.entity().downgrade(); workspace.toggle_modal(window, cx, |window, cx| { RemoteServerProjects::new(window, cx, weak) }); @@ -326,14 +326,14 @@ impl RemoteServerProjects { _: &mut Context, ) { 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)) }); } pub fn open(workspace: Entity, window: &mut Window, cx: &mut App) { 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)) }) } @@ -523,7 +523,7 @@ impl RemoteServerProjects { let Some(Some(session)) = session else { workspace .update_in(&mut cx, |workspace, window, cx| { - let weak = cx.model().downgrade(); + let weak = cx.entity().downgrade(); workspace.toggle_modal(window, cx, |window, cx| { RemoteServerProjects::new(window, cx, weak) }); @@ -535,7 +535,7 @@ impl RemoteServerProjects { workspace .update_in(&mut cx, |workspace, window, cx| { let app_state = workspace.app_state().clone(); - let weak = cx.model().downgrade(); + let weak = cx.entity().downgrade(); let project = project::Project::ssh( session, app_state.client.clone(), @@ -1152,7 +1152,7 @@ impl RemoteServerProjects { let connection_string = connection_string.clone(); move |_, _: &menu::Confirm, window, cx| { remove_ssh_server( - cx.model().clone(), + cx.entity().clone(), server_index, connection_string.clone(), window, @@ -1172,7 +1172,7 @@ impl RemoteServerProjects { .child(Label::new("Remove Server").color(Color::Error)) .on_click(cx.listener(move |_, _, window, cx| { remove_ssh_server( - cx.model().clone(), + cx.entity().clone(), server_index, connection_string.clone(), window, @@ -1280,7 +1280,7 @@ impl RemoteServerProjects { 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() .id("ssh-connect-new-server-container") .track_focus(&state.add_new_server.focus_handle) diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rs index f15d32f5b3..b7a0ea5395 100644 --- a/crates/remote_server/src/headless_project.rs +++ b/crates/remote_server/src/headless_project.rs @@ -166,19 +166,19 @@ impl HeadlessProject { 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, &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, &task_store); session.subscribe_to_entity(SSH_PROJECT_ID, &toolchain_store); 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_model(), Self::handle_get_path_metadata); - client.add_request_handler(cx.weak_model(), Self::handle_shutdown_remote_server); - client.add_request_handler(cx.weak_model(), Self::handle_ping); + client.add_request_handler(cx.weak_entity(), Self::handle_list_remote_directory); + client.add_request_handler(cx.weak_entity(), Self::handle_get_path_metadata); + client.add_request_handler(cx.weak_entity(), Self::handle_shutdown_remote_server); + client.add_request_handler(cx.weak_entity(), Self::handle_ping); 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_new_buffer); diff --git a/crates/repl/src/notebook/notebook_ui.rs b/crates/repl/src/notebook/notebook_ui.rs index 53437b59bf..dde11a6aab 100644 --- a/crates/repl/src/notebook/notebook_ui.rs +++ b/crates/repl/src/notebook/notebook_ui.rs @@ -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 this = cx.model(); + let this = cx.entity(); let cell_list = ListState::new( cell_count, gpui::ListAlignment::Top, diff --git a/crates/repl/src/repl_sessions_ui.rs b/crates/repl/src/repl_sessions_ui.rs index 6ac843a10b..480958976a 100644 --- a/crates/repl/src/repl_sessions_ui.rs +++ b/crates/repl/src/repl_sessions_ui.rs @@ -92,7 +92,7 @@ pub fn init(cx: &mut App) { 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 language.name() == "Python".into() { diff --git a/crates/repl/src/session.rs b/crates/repl/src/session.rs index 7851f9ed32..f2d3259e67 100644 --- a/crates/repl/src/session.rs +++ b/crates/repl/src/session.rs @@ -245,7 +245,7 @@ impl Session { 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() { KernelSpecification::Jupyter(kernel_specification) @@ -417,7 +417,7 @@ impl Session { }; 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 on_close: CloseBlockFn = Arc::new( diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 58dcb95b36..cd7015a9a6 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -516,7 +516,7 @@ impl ToolbarItemView for BufferSearchBar { if let Some(searchable_item_handle) = 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 = Some(searchable_item_handle.subscribe_to_search_events( diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 55d796be3a..7506bc6727 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -820,7 +820,7 @@ impl ProjectSearchView { 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 search = cx.new(|cx| ProjectSearchView::new(weak_workspace, model, window, cx, None)); @@ -879,7 +879,7 @@ impl ProjectSearchView { model.search(new_query, cx); model }); - let weak_workspace = cx.model().downgrade(); + let weak_workspace = cx.entity().downgrade(); workspace.add_item_to_active_pane( Box::new( cx.new(|cx| { @@ -937,7 +937,7 @@ impl ProjectSearchView { 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_view = cx.new(|cx| { diff --git a/crates/semantic_index/src/project_index_debug_view.rs b/crates/semantic_index/src/project_index_debug_view.rs index 14b857f88e..1a885f0eb8 100644 --- a/crates/semantic_index/src/project_index_debug_view.rs +++ b/crates/semantic_index/src/project_index_debug_view.rs @@ -115,7 +115,7 @@ impl ProjectIndexDebugView { .collect::>(); this.update(&mut cx, |this, cx| { - let view = cx.model().downgrade(); + let view = cx.entity().downgrade(); this.selected_path = Some(PathState { path: file_path, list_state: ListState::new( @@ -224,7 +224,7 @@ impl Render for ProjectIndexDebugView { .into_any_element() } else { let mut list = uniform_list( - cx.model().clone(), + cx.entity().clone(), "ProjectIndexDebugView", self.rows.len(), move |this, range, _, cx| { diff --git a/crates/snippets_ui/src/snippets_ui.rs b/crates/snippets_ui/src/snippets_ui.rs index 5bb86557f4..4d86e615ce 100644 --- a/crates/snippets_ui/src/snippets_ui.rs +++ b/crates/snippets_ui/src/snippets_ui.rs @@ -58,7 +58,7 @@ impl ScopeSelector { cx: &mut Context, ) -> Self { 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)); diff --git a/crates/storybook/src/stories/indent_guides.rs b/crates/storybook/src/stories/indent_guides.rs index 746022c1ec..eb8f4012a7 100644 --- a/crates/storybook/src/stories/indent_guides.rs +++ b/crates/storybook/src/stories/indent_guides.rs @@ -39,7 +39,7 @@ impl Render for IndentGuidesStory { .child( v_flex().size_full().child( uniform_list( - cx.model().clone(), + cx.entity().clone(), "some-list", self.depths.len(), |this, range, cx| { @@ -60,7 +60,7 @@ impl Render for IndentGuidesStory { ) .with_sizing_behavior(gpui::ListSizingBehavior::Infer) .with_decoration(ui::indent_guides( - cx.model().clone(), + cx.entity().clone(), px(16.), ui::IndentGuideColors { default: Color::Info.color(cx), diff --git a/crates/tab_switcher/src/tab_switcher.rs b/crates/tab_switcher/src/tab_switcher.rs index e6ac048212..5af89a92d2 100644 --- a/crates/tab_switcher/src/tab_switcher.rs +++ b/crates/tab_switcher/src/tab_switcher.rs @@ -94,7 +94,7 @@ impl TabSwitcher { let delegate = TabSwitcherDelegate::new( project, action, - cx.model().downgrade(), + cx.entity().downgrade(), weak_pane, window, cx, diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 5f5f2dc668..315021b514 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -903,7 +903,7 @@ pub fn new_terminal_pane( cx: &mut Context, ) -> Entity { 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 mut pane = Pane::new( workspace.clone(), @@ -923,7 +923,7 @@ pub fn new_terminal_pane( let split_closure_terminal_panel = terminal_panel.downgrade(); pane.set_can_split(Some(Arc::new(move |pane, dragged_item, _window, cx| { if let Some(tab) = dragged_item.downcast_ref::() { - 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 .update(cx, |terminal_panel, _| { let current_panes = terminal_panel.center.panes(); @@ -963,7 +963,7 @@ pub fn new_terminal_pane( return ControlFlow::Break(()); }; if let Some(tab) = dropped_item.downcast_ref::() { - let this_pane = cx.model().clone(); + let this_pane = cx.entity().clone(); let item = if tab.pane == this_pane { pane.item_for_index(tab.ix) } else { diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 0e0f3a7132..ab300f5ec5 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -218,7 +218,7 @@ impl TerminalView { } } - pub fn model(&self) -> &Entity { + pub fn entity(&self) -> &Entity { &self.terminal } @@ -1125,7 +1125,7 @@ impl TerminalView { impl Render for TerminalView { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { 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); @@ -1771,7 +1771,7 @@ mod tests { let project = Project::test(params.fs.clone(), [], cx).await; let workspace = cx .add_window(|window, cx| Workspace::test_new(project.clone(), window, cx)) - .root_model(cx) + .root(cx) .unwrap(); (project, workspace) diff --git a/crates/theme_selector/src/theme_selector.rs b/crates/theme_selector/src/theme_selector.rs index 931a41ca9b..67e282ac49 100644 --- a/crates/theme_selector/src/theme_selector.rs +++ b/crates/theme_selector/src/theme_selector.rs @@ -33,7 +33,7 @@ pub fn toggle( let fs = workspace.app_state().fs.clone(); workspace.toggle_modal(window, cx, |window, cx| { let delegate = ThemeSelectorDelegate::new( - cx.model().downgrade(), + cx.entity().downgrade(), fs, toggle.themes_filter.as_ref(), cx, diff --git a/crates/toolchain_selector/src/toolchain_selector.rs b/crates/toolchain_selector/src/toolchain_selector.rs index 4b1eb29fbf..5754cf1661 100644 --- a/crates/toolchain_selector/src/toolchain_selector.rs +++ b/crates/toolchain_selector/src/toolchain_selector.rs @@ -96,7 +96,7 @@ impl ToolchainSelector { window: &mut Window, cx: &mut Context, ) -> Self { - let toolchain_selector = cx.model().downgrade(); + let toolchain_selector = cx.entity().downgrade(); let picker = cx.new(|cx| { let delegate = ToolchainSelectorDelegate::new( active_toolchain, diff --git a/crates/ui/src/components/context_menu.rs b/crates/ui/src/components/context_menu.rs index baa1a93b83..b4e01a05d2 100644 --- a/crates/ui/src/components/context_menu.rs +++ b/crates/ui/src/components/context_menu.rs @@ -539,7 +539,7 @@ impl Render for ContextMenu { disabled, }) => { let handler = handler.clone(); - let menu = cx.model().downgrade(); + let menu = cx.entity().downgrade(); let icon_color = if *disabled { Color::Muted } else { @@ -637,7 +637,7 @@ impl Render for ContextMenu { selectable, } => { let handler = handler.clone(); - let menu = cx.model().downgrade(); + let menu = cx.entity().downgrade(); let selectable = *selectable; ListItem::new(ix) .inset(true) diff --git a/crates/vcs_menu/src/lib.rs b/crates/vcs_menu/src/lib.rs index a73967db95..e4a63d9f0f 100644 --- a/crates/vcs_menu/src/lib.rs +++ b/crates/vcs_menu/src/lib.rs @@ -35,7 +35,7 @@ impl BranchList { window: &mut Window, cx: &mut Context, ) { - let this = cx.model().clone(); + let this = cx.entity().clone(); cx.spawn_in(window, |_, mut cx| async move { // Modal branch picker has a longer trailoff than a popover one. let delegate = BranchListDelegate::new(this.clone(), 70, &cx).await?; diff --git a/crates/vim/src/mode_indicator.rs b/crates/vim/src/mode_indicator.rs index e9b39ef31c..8292970a53 100644 --- a/crates/vim/src/mode_indicator.rs +++ b/crates/vim/src/mode_indicator.rs @@ -20,7 +20,7 @@ impl ModeIndicator { }) .detach(); - let handle = cx.model().clone(); + let handle = cx.entity().clone(); let window_handle = window.window_handle(); cx.observe_new::(move |_, window, cx| { let Some(window) = window else { @@ -29,7 +29,7 @@ impl ModeIndicator { if window.window_handle() != window_handle { return; } - let vim = cx.model().clone(); + let vim = cx.entity().clone(); handle.update(cx, |_, cx| { cx.subscribe(&vim, |mode_indicator, vim, event, cx| match event { VimEvent::Focused => { diff --git a/crates/vim/src/normal/repeat.rs b/crates/vim/src/normal/repeat.rs index 188a28a09b..2a0f683bc9 100644 --- a/crates/vim/src/normal/repeat.rs +++ b/crates/vim/src/normal/repeat.rs @@ -130,7 +130,7 @@ impl Replayer { text, utf16_range_to_replace, } => { - let Some(Some(workspace)) = window.root_model::() else { + let Some(Some(workspace)) = window.root::() else { return; }; let Some(editor) = workspace diff --git a/crates/vim/src/normal/search.rs b/crates/vim/src/normal/search.rs index 69734fa3cc..948141c4e7 100644 --- a/crates/vim/src/normal/search.rs +++ b/crates/vim/src/normal/search.rs @@ -291,7 +291,7 @@ impl Vim { }; let count = Vim::take_count(cx).unwrap_or(1); let prior_selections = self.editor_selections(window, cx); - let vim = cx.model().clone(); + let vim = cx.entity().clone(); let searched = pane.update(cx, |pane, cx| { self.search.direction = direction; @@ -425,7 +425,7 @@ impl Vim { result.notify_err(workspace, cx); }) } - let vim = cx.model().clone(); + let vim = cx.entity().clone(); pane.update(cx, |pane, cx| { let Some(search_bar) = pane.toolbar().read(cx).item_of_type::() else { return; diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index bfcae424e5..be54fed084 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -245,7 +245,7 @@ impl Vim { const NAMESPACE: &'static str = "vim"; pub fn new(window: &mut Window, cx: &mut Context) -> Entity { - let editor = cx.model().clone(); + let editor = cx.entity().clone(); cx.new(|cx| Vim { mode: Mode::Normal, @@ -377,7 +377,7 @@ impl Vim { editor.unregister_addon::(); editor.set_relative_line_number(None, cx); if let Some(vim) = Vim::globals(cx).focused_vim() { - if vim.entity_id() == cx.model().entity_id() { + if vim.entity_id() == cx.entity().entity_id() { Vim::globals(cx).focused_vim = None; } } @@ -398,7 +398,7 @@ impl Vim { } pub fn workspace(&self, window: &mut Window) -> Option> { - window.root_model::().flatten() + window.root::().flatten() } pub fn pane(&self, window: &mut Window, cx: &mut Context) -> Option> { @@ -797,7 +797,7 @@ impl Vim { if VimSettings::get_global(cx).toggle_relative_line_numbers { if let Some(old_vim) = Vim::globals(cx).focused_vim() { - if old_vim.entity_id() != cx.model().entity_id() { + if old_vim.entity_id() != cx.entity().entity_id() { old_vim.update(cx, |vim, cx| { vim.update_editor(window, cx, |_, editor, _, cx| { editor.set_relative_line_number(None, cx) @@ -816,7 +816,7 @@ impl Vim { }); } } - Vim::globals(cx).focused_vim = Some(cx.model().downgrade()); + Vim::globals(cx).focused_vim = Some(cx.entity().downgrade()); } fn blurred(&mut self, window: &mut Window, cx: &mut Context) { diff --git a/crates/welcome/src/base_keymap_picker.rs b/crates/welcome/src/base_keymap_picker.rs index 6a07260b29..e052062918 100644 --- a/crates/welcome/src/base_keymap_picker.rs +++ b/crates/welcome/src/base_keymap_picker.rs @@ -30,7 +30,7 @@ pub fn toggle( let fs = workspace.app_state().fs.clone(); workspace.toggle_modal(window, cx, |window, cx| { BaseKeymapSelector::new( - BaseKeymapSelectorDelegate::new(cx.model().downgrade(), fs, cx), + BaseKeymapSelectorDelegate::new(cx.entity().downgrade(), fs, cx), window, cx, ) diff --git a/crates/welcome/src/multibuffer_hint.rs b/crates/welcome/src/multibuffer_hint.rs index e3b9342c21..cfea0290b4 100644 --- a/crates/welcome/src/multibuffer_hint.rs +++ b/crates/welcome/src/multibuffer_hint.rs @@ -109,7 +109,7 @@ impl ToolbarItemView for MultibufferHint { return ToolbarItemLocation::Hidden; }; - let this = cx.model().downgrade(); + let this = cx.entity().downgrade(); self.subscription = Some(active_pane_item.subscribe_to_item_events( window, cx, diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index b4736a4e91..2d1e555383 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -240,7 +240,7 @@ impl Dock { cx: &mut Context, ) -> Entity { let focus_handle = cx.focus_handle(); - let workspace = cx.model().clone(); + let workspace = cx.entity().clone(); let dock = cx.new(|cx| { let focus_subscription = cx.on_focus(&focus_handle, window, |dock: &mut Dock, window, cx| { diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rs index ef2d414c61..afa302158a 100644 --- a/crates/workspace/src/notifications.rs +++ b/crates/workspace/src/notifications.rs @@ -265,7 +265,7 @@ impl Render for LanguageServerPrompt { ) .child(Label::new(request.message.to_string()).size(LabelSize::Small)) .children(request.actions.iter().enumerate().map(|(ix, action)| { - let this_handle = cx.model().clone(); + let this_handle = cx.entity().clone(); Button::new(ix, action.title.clone()) .size(ButtonSize::Large) .on_click(move |_, window, cx| { diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 6e53b798cb..eeb810bc23 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -396,7 +396,7 @@ impl Pane { cx.subscribe(&project, Self::project_events), ]; - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); Self { alternate_file_items: (None, None), focus_handle, @@ -756,7 +756,7 @@ impl Pane { fn navigate_backward(&mut self, window: &mut Window, cx: &mut Context) { if let Some(workspace) = self.workspace.upgrade() { - let pane = cx.model().downgrade(); + let pane = cx.entity().downgrade(); window.defer(cx, move |window, cx| { workspace.update(cx, |workspace, cx| { workspace.go_back(pane, window, cx).detach_and_log_err(cx) @@ -767,7 +767,7 @@ impl Pane { fn navigate_forward(&mut self, window: &mut Window, cx: &mut Context) { if let Some(workspace) = self.workspace.upgrade() { - let pane = cx.model().downgrade(); + let pane = cx.entity().downgrade(); window.defer(cx, move |window, cx| { workspace.update(cx, |workspace, cx| { workspace @@ -1992,7 +1992,7 @@ impl Pane { fn update_status_bar(&mut self, window: &mut Window, cx: &mut Context) { let workspace = self.workspace.clone(); - let pane = cx.model().clone(); + let pane = cx.entity().clone(); window.defer(cx, move |window, cx| { let Ok(status_bar) = workspace.update(cx, |workspace, _| workspace.status_bar.clone()) @@ -2044,7 +2044,7 @@ impl Pane { fn pin_tab_at(&mut self, ix: usize, window: &mut Window, cx: &mut Context) { maybe!({ - let pane = cx.model().clone(); + let pane = cx.entity().clone(); let destination_index = self.pinned_tab_count.min(ix); self.pinned_tab_count += 1; let id = self.item_for_index(ix)?.item_id(); @@ -2067,7 +2067,7 @@ impl Pane { fn unpin_tab_at(&mut self, ix: usize, window: &mut Window, cx: &mut Context) { maybe!({ - let pane = cx.model().clone(); + let pane = cx.entity().clone(); self.pinned_tab_count = self.pinned_tab_count.checked_sub(1)?; let destination_index = self.pinned_tab_count; @@ -2214,7 +2214,7 @@ impl Pane { .on_drag( DraggedTab { item: item.boxed_clone(), - pane: cx.model().clone(), + pane: cx.entity().clone(), detail, is_active, ix, @@ -2328,7 +2328,7 @@ impl Pane { }; let is_pinned = self.is_tab_pinned(ix); - let pane = cx.model().downgrade(); + let pane = cx.entity().downgrade(); let menu_context = item.item_focus_handle(cx); right_click_menu(ix).trigger(tab).menu(move |window, cx| { let pane = pane.clone(); @@ -2534,7 +2534,7 @@ impl Pane { let navigate_backward = IconButton::new("navigate_backward", IconName::ArrowLeft) .icon_size(IconSize::Small) .on_click({ - let model = cx.model().clone(); + let model = cx.entity().clone(); move |_, window, cx| model.update(cx, |pane, cx| pane.navigate_backward(window, cx)) }) .disabled(!self.can_navigate_backward()) @@ -2548,7 +2548,7 @@ impl Pane { let navigate_forward = IconButton::new("navigate_forward", IconName::ArrowRight) .icon_size(IconSize::Small) .on_click({ - let model = cx.model().clone(); + let model = cx.entity().clone(); move |_, window, cx| model.update(cx, |pane, cx| pane.navigate_forward(window, cx)) }) .disabled(!self.can_navigate_forward()) @@ -2732,7 +2732,7 @@ impl Pane { return; } } - let mut to_pane = cx.model().clone(); + let mut to_pane = cx.entity().clone(); let split_direction = self.drag_split_direction; let item_id = dragged_tab.item.item_id(); if let Some(preview_item_id) = self.preview_item_id { @@ -2821,7 +2821,7 @@ impl Pane { return; } } - let mut to_pane = cx.model().clone(); + let mut to_pane = cx.entity().clone(); let split_direction = self.drag_split_direction; let project_entry_id = *project_entry_id; self.workspace @@ -2895,7 +2895,7 @@ impl Pane { return; } } - let mut to_pane = cx.model().clone(); + let mut to_pane = cx.entity().clone(); let mut split_direction = self.drag_split_direction; let paths = paths.paths().to_vec(); let is_remote = self @@ -3246,7 +3246,7 @@ impl Render for Pane { MouseButton::Navigate(NavigationDirection::Back), cx.listener(|pane, _, window, cx| { if let Some(workspace) = pane.workspace.upgrade() { - let pane = cx.model().downgrade(); + let pane = cx.entity().downgrade(); window.defer(cx, move |window, cx| { workspace.update(cx, |workspace, cx| { workspace.go_back(pane, window, cx).detach_and_log_err(cx) @@ -3259,7 +3259,7 @@ impl Render for Pane { MouseButton::Navigate(NavigationDirection::Forward), cx.listener(|pane, _, window, cx| { if let Some(workspace) = pane.workspace.upgrade() { - let pane = cx.model().downgrade(); + let pane = cx.entity().downgrade(); window.defer(cx, move |window, cx| { workspace.update(cx, |workspace, cx| { workspace diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index b000d033e8..7409dead14 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -699,7 +699,7 @@ impl PaneAxis { basis, self.flexes.clone(), self.bounding_boxes.clone(), - cx.model().downgrade(), + cx.entity().downgrade(), ) .children(self.members.iter().enumerate().map(|(ix, member)| { if member.contains(active_pane) { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 6b0c551d4d..562a6ad5e1 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -941,7 +941,7 @@ impl Workspace { }) .detach(); - let weak_handle = cx.model().downgrade(); + let weak_handle = cx.entity().downgrade(); let pane_history_timestamp = Arc::new(AtomicUsize::new(0)); let center_pane = cx.new(|cx| { @@ -1216,7 +1216,7 @@ impl Workspace { } let window = if let Some(window) = requesting_window { cx.update_window(window.into(), |_, window, cx| { - window.replace_root_model(cx, |window, cx| { + window.replace_root(cx, |window, cx| { Workspace::new( Some(workspace_id), project_handle.clone(), @@ -4962,7 +4962,7 @@ impl Workspace { } pub fn for_window(window: &mut Window, _: &mut App) -> Option> { - window.root_model().flatten() + window.root().flatten() } pub fn zoomed_item(&self) -> Option<&AnyWeakView> { @@ -5265,7 +5265,7 @@ impl Render for Workspace { .border_b_1() .border_color(colors.border) .child({ - let this = cx.model().clone(); + let this = cx.entity().clone(); canvas( move |bounds, window, cx| { this.update(cx, |this, cx| { @@ -5477,8 +5477,8 @@ impl WorkspaceStore { Self { workspaces: Default::default(), _subscriptions: vec![ - client.add_request_handler(cx.weak_model(), Self::handle_follow), - client.add_message_handler(cx.weak_model(), Self::handle_update_followers), + client.add_request_handler(cx.weak_entity(), Self::handle_follow), + client.add_message_handler(cx.weak_entity(), Self::handle_update_followers), ], client, } @@ -6146,7 +6146,7 @@ pub fn open_ssh_project( } cx.update_window(window.into(), |_, window, cx| { - window.replace_root_model(cx, |window, cx| { + window.replace_root(cx, |window, cx| { let mut workspace = Workspace::new(Some(workspace_id), project, app_state.clone(), window, cx); diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index e3b911ec3e..3a1273191e 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -824,7 +824,7 @@ impl Worktree { pub fn root_file(&self, cx: &Context) -> Option> { let entry = self.root_entry()?; - Some(File::for_entry(entry.clone(), cx.model())) + Some(File::for_entry(entry.clone(), cx.entity())) } pub fn observe_updates(&mut self, project_id: u64, cx: &Context, callback: F) @@ -1504,7 +1504,7 @@ impl LocalWorktree { let entry = self.refresh_entry(path.clone(), None, cx); let is_private = self.is_path_private(path.as_ref()); - let worktree = cx.weak_model(); + let worktree = cx.weak_entity(); cx.background_executor().spawn(async move { let abs_path = abs_path?; let content = fs.load_bytes(&abs_path).await?; diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index 15f2866144..533ae7eb87 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -1884,7 +1884,7 @@ async fn test_random_worktree_changes(cx: &mut TestAppContext, mut rng: StdRng) // all changes to the worktree's snapshot. fn check_worktree_change_events(tree: &mut Worktree, cx: &mut Context) { let mut entries = tree.entries(true, 0).cloned().collect::>(); - cx.subscribe(&cx.model(), move |tree, _, event, _| { + cx.subscribe(&cx.entity(), move |tree, _, event, _| { if let Event::UpdatedEntries(changes) = event { for (path, _, change_type) in changes.iter() { let entry = tree.entry_for_path(path).cloned(); diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 7c9e48a219..93ad29b236 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -724,7 +724,7 @@ fn handle_open_request(request: OpenRequest, app_state: Arc, cx: &mut let workspace_window = workspace::get_any_active_workspace(app_state, cx.clone()).await?; - let workspace = workspace_window.root_model(&cx)?; + let workspace = workspace_window.entity(&cx)?; let mut promises = Vec::new(); for (channel_id, heading) in request.open_channel_notes { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 8fb4ef87a7..fddbb2406b 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -143,7 +143,7 @@ pub fn initialize_workspace( return; }; - let workspace_handle = cx.model().clone(); + let workspace_handle = cx.entity().clone(); let center_pane = workspace.active_pane().clone(); initialize_pane(workspace, ¢er_pane, window, cx); cx.subscribe_in(&workspace_handle, window, { @@ -214,7 +214,7 @@ pub fn initialize_workspace( auto_update_ui::notify_of_any_new_update(window, cx); - let handle = cx.model().downgrade(); + let handle = cx.entity().downgrade(); window.on_window_should_close(cx, move |window, cx| { handle .update(cx, |workspace, cx| { @@ -1221,7 +1221,7 @@ fn show_keymap_file_load_error( let parsed_markdown = Rc::new(parsed_markdown.await); cx.update(|cx| { show_app_notification(notification_id, cx, move |cx| { - let workspace_handle = cx.model().downgrade(); + let workspace_handle = cx.entity().downgrade(); let parsed_markdown = parsed_markdown.clone(); cx.new(move |_cx| { MessageNotification::new_from_builder(move |window, cx| { @@ -2574,7 +2574,7 @@ mod tests { .unwrap(); assert_eq!( - opened_workspace.root_model(cx).unwrap().entity_id(), + opened_workspace.root(cx).unwrap().entity_id(), workspace.entity_id(), "Excluded files in subfolders of a workspace root should be opened in the workspace" ); diff --git a/crates/zed/src/zed/inline_completion_registry.rs b/crates/zed/src/zed/inline_completion_registry.rs index c44e0f121d..10a6f5549f 100644 --- a/crates/zed/src/zed/inline_completion_registry.rs +++ b/crates/zed/src/zed/inline_completion_registry.rs @@ -29,7 +29,7 @@ pub fn init(client: Arc, user_store: Entity, cx: &mut App) { return; }; - let editor_handle = cx.model().downgrade(); + let editor_handle = cx.entity().downgrade(); cx.on_release({ let editor_handle = editor_handle.clone(); let editors = editors.clone(); @@ -115,9 +115,8 @@ pub fn init(client: Arc, user_store: Entity, cx: &mut App) { return; }; - let Some(workspace) = window - .downcast::() - .and_then(|w| w.root_model(cx).ok()) + let Some(workspace) = + window.downcast::().and_then(|w| w.root(cx).ok()) else { return; }; diff --git a/crates/zed_predict_tos/src/zed_predict_tos.rs b/crates/zed_predict_tos/src/zed_predict_tos.rs index 3840159a41..9d312bba75 100644 --- a/crates/zed_predict_tos/src/zed_predict_tos.rs +++ b/crates/zed_predict_tos/src/zed_predict_tos.rs @@ -36,7 +36,7 @@ impl ZedPredictTos { cx: &mut App, ) { workspace.update(cx, |this, cx| { - let workspace = cx.model().clone(); + let workspace = cx.entity().clone(); this.toggle_modal(window, cx, |_window, cx| { ZedPredictTos::new(workspace, user_store, cx) });