Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use read-only access methods for read-only entity operations (#31479)
Joseph T. Lyonsc20853269394
diff --git a/crates/agent/src/context_picker/completion_provider.rs b/crates/agent/src/context_picker/completion_provider.rsindex 7d760dd2952..245ddbc717c 100644--- a/crates/agent/src/context_picker/completion_provider.rs+++ b/crates/agent/src/context_picker/completion_provider.rs@@ -553,7 +553,7 @@ impl ContextPickerCompletionProvider {let url_to_fetch = url_to_fetch.clone();cx.spawn(async move |cx| {if let Some(context) = context_store- .update(cx, |context_store, _| {+ .read_with(cx, |context_store, _| {context_store.get_url_context(url_to_fetch.clone())}).ok()?diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rsindex 4c00e4414e9..c643b4b737e 100644--- a/crates/assistant_context_editor/src/context_editor.rs+++ b/crates/assistant_context_editor/src/context_editor.rs@@ -1903,7 +1903,7 @@ impl ContextEditor {.on_click(cx.listener(|this, _event, _window, cx| {let client = this.workspace- .update(cx, |workspace, _| workspace.client().clone())+ .read_with(cx, |workspace, _| workspace.client().clone()).log_err();if let Some(client) = client {diff --git a/crates/assistant_context_editor/src/slash_command_picker.rs b/crates/assistant_context_editor/src/slash_command_picker.rsindex 384fdc57900..3cafebdd74d 100644--- a/crates/assistant_context_editor/src/slash_command_picker.rs+++ b/crates/assistant_context_editor/src/slash_command_picker.rs@@ -338,7 +338,7 @@ wherelet handle = self.active_context_editor- .update(cx, |this, _| this.slash_menu_handle.clone())+ .read_with(cx, |this, _| this.slash_menu_handle.clone()).ok();PopoverMenu::new("model-switcher").menu(move |_window, _cx| Some(picker_view.clone()))diff --git a/crates/assistant_tools/src/edit_agent/evals/fixtures/disable_cursor_blinking/before.rs b/crates/assistant_tools/src/edit_agent/evals/fixtures/disable_cursor_blinking/before.rsindex 607daa8ce3a..9481267a415 100644--- a/crates/assistant_tools/src/edit_agent/evals/fixtures/disable_cursor_blinking/before.rs+++ b/crates/assistant_tools/src/edit_agent/evals/fixtures/disable_cursor_blinking/before.rs@@ -19812,7 +19812,7 @@ impl SemanticsProvider for Entity<Project> {PrepareRenameResponse::InvalidPosition => None,PrepareRenameResponse::OnlyUnpreparedRenameSupported => {// Fallback on using TreeSitter info to determine identifier range- buffer.update(cx, |buffer, _| {+ buffer.read_with(cx, |buffer, _| {let snapshot = buffer.snapshot();let (range, kind) = snapshot.surrounding_word(position);if kind != Some(CharKind::Word) {diff --git a/crates/assistant_tools/src/terminal_tool.rs b/crates/assistant_tools/src/terminal_tool.rsindex 9b3ee0c2d2f..c63ede10927 100644--- a/crates/assistant_tools/src/terminal_tool.rs+++ b/crates/assistant_tools/src/terminal_tool.rs@@ -275,7 +275,7 @@ impl Tool for TerminalTool {let exit_status = terminal.update(cx, |terminal, cx| terminal.wait_for_completed_task(cx))?.await;- let (content, content_line_count) = terminal.update(cx, |terminal, _| {+ let (content, content_line_count) = terminal.read_with(cx, |terminal, _| {(terminal.get_content(), terminal.total_lines())})?;diff --git a/crates/call/src/call_impl/mod.rs b/crates/call/src/call_impl/mod.rsindex 459133fe04e..71c31493241 100644--- a/crates/call/src/call_impl/mod.rs+++ b/crates/call/src/call_impl/mod.rs@@ -116,7 +116,7 @@ impl ActiveCall {envelope: TypedEnvelope<proto::IncomingCall>,mut cx: AsyncApp,) -> Result<proto::Ack> {- let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;+ let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;let call = IncomingCall {room_id: envelope.payload.room_id,participants: user_storediff --git a/crates/channel/src/channel_chat.rs b/crates/channel/src/channel_chat.rsindex 65e313dece2..8394972d437 100644--- a/crates/channel/src/channel_chat.rs+++ b/crates/channel/src/channel_chat.rs@@ -387,7 +387,7 @@ impl ChannelChat {let loaded_messages = messages_from_proto(proto_messages, &user_store, cx).await?;let first_loaded_message_id = loaded_messages.first().map(|m| m.id);- let loaded_message_ids = this.update(cx, |this, _| {+ let loaded_message_ids = this.read_with(cx, |this, _| {let mut loaded_message_ids: HashSet<u64> = HashSet::default();for message in loaded_messages.iter() {if let Some(saved_message_id) = message.id.into() {@@ -457,7 +457,7 @@ impl ChannelChat {).await?;- let pending_messages = this.update(cx, |this, _| {+ let pending_messages = this.read_with(cx, |this, _| {this.pending_messages().cloned().collect::<Vec<_>>()})?;@@ -531,7 +531,7 @@ impl ChannelChat {message: TypedEnvelope<proto::ChannelMessageSent>,mut cx: AsyncApp,) -> Result<()> {- let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;+ let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;let message = message.payload.message.context("empty message")?;let message_id = message.id;@@ -563,7 +563,7 @@ impl ChannelChat {message: TypedEnvelope<proto::ChannelMessageUpdate>,mut cx: AsyncApp,) -> Result<()> {- let user_store = this.update(&mut cx, |this, _| this.user_store.clone())?;+ let user_store = this.read_with(&mut cx, |this, _| this.user_store.clone())?;let message = message.payload.message.context("empty message")?;let message = ChannelMessage::from_proto(message, &user_store, &mut cx).await?;diff --git a/crates/channel/src/channel_store.rs b/crates/channel/src/channel_store.rsindex 57a4864b063..3fdc49a904f 100644--- a/crates/channel/src/channel_store.rs+++ b/crates/channel/src/channel_store.rs@@ -333,7 +333,7 @@ impl ChannelStore {if let Some(request) = request {let response = request.await?;let this = this.upgrade().context("channel store dropped")?;- let user_store = this.update(cx, |this, _| this.user_store.clone())?;+ let user_store = this.read_with(cx, |this, _| this.user_store.clone())?;ChannelMessage::from_proto_vec(response.messages, &user_store, cx).await} else {Ok(Vec::new())@@ -478,7 +478,7 @@ impl ChannelStore {hash_map::Entry::Vacant(e) => {let task = cx.spawn(async move |this, cx| {- let channel = this.update(cx, |this, _| {+ let channel = this.read_with(cx, |this, _| {this.channel_for_id(channel_id).cloned().ok_or_else(|| {Arc::new(anyhow!("no channel for id: {channel_id}"))})@@ -848,7 +848,7 @@ impl ChannelStore {message: TypedEnvelope<proto::UpdateChannels>,mut cx: AsyncApp,) -> Result<()> {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {this.update_channels_tx.unbounded_send(message.payload).unwrap();diff --git a/crates/client/src/client.rs b/crates/client/src/client.rsindex 6c8c702c0fa..c035c36258e 100644--- a/crates/client/src/client.rs+++ b/crates/client/src/client.rs@@ -1850,7 +1850,7 @@ mod tests {let (done_tx2, done_rx2) = smol::channel::unbounded();AnyProtoClient::from(client.clone()).add_entity_message_handler(move |entity: Entity<TestEntity>, _: TypedEnvelope<proto::JoinProject>, mut cx| {- match entity.update(&mut cx, |entity, _| entity.id).unwrap() {+ match entity.read_with(&mut cx, |entity, _| entity.id).unwrap() {1 => done_tx1.try_send(()).unwrap(),2 => done_tx2.try_send(()).unwrap(),_ => unreachable!(),diff --git a/crates/client/src/user.rs b/crates/client/src/user.rsindex c5dbf27c511..27120cbbacd 100644--- a/crates/client/src/user.rs+++ b/crates/client/src/user.rs@@ -324,7 +324,7 @@ impl UserStore {message: TypedEnvelope<proto::UpdateContacts>,mut cx: AsyncApp,) -> Result<()> {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {this.update_contacts_tx.unbounded_send(UpdateContacts::Update(message.payload)).unwrap();@@ -660,7 +660,7 @@ impl UserStore {.await?;}- this.update(cx, |this, _| {+ this.read_with(cx, |this, _| {user_ids.iter().map(|user_id| {@@ -703,7 +703,7 @@ impl UserStore {let load_users = self.get_users(vec![user_id], cx);cx.spawn(async move |this, cx| {load_users.await?;- this.update(cx, |this, _| {+ this.read_with(cx, |this, _| {this.users.get(&user_id).cloned()diff --git a/crates/collab_ui/src/chat_panel/message_editor.rs b/crates/collab_ui/src/chat_panel/message_editor.rsindex 46d3b36bd46..5979617674f 100644--- a/crates/collab_ui/src/chat_panel/message_editor.rs+++ b/crates/collab_ui/src/chat_panel/message_editor.rs@@ -352,7 +352,7 @@ impl MessageEditor {) -> Option<(Anchor, String, Vec<StringMatchCandidate>)> {let end_offset = end_anchor.to_offset(buffer.read(cx));- let query = buffer.update(cx, |buffer, _| {+ let query = buffer.read_with(cx, |buffer, _| {let mut query = String::new();for ch in buffer.reversed_chars_at(end_offset).take(100) {if ch == '@' {@@ -410,7 +410,7 @@ impl MessageEditor {let end_offset = end_anchor.to_offset(buffer.read(cx));- let query = buffer.update(cx, |buffer, _| {+ let query = buffer.read_with(cx, |buffer, _| {let mut query = String::new();for ch in buffer.reversed_chars_at(end_offset).take(100) {if ch == ':' {diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rsindex 905b9b04ca7..3d03a987ed9 100644--- a/crates/collab_ui/src/collab_panel.rs+++ b/crates/collab_ui/src/collab_panel.rs@@ -428,7 +428,7 @@ impl CollabPanel {fn serialize(&mut self, cx: &mut Context<Self>) {let Some(serialization_key) = self.workspace- .update(cx, |workspace, _| CollabPanel::serialization_key(workspace))+ .read_with(cx, |workspace, _| CollabPanel::serialization_key(workspace)).ok().flatten()else {diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rsindex 4b19ee83002..9c88af9d163 100644--- a/crates/command_palette/src/command_palette.rs+++ b/crates/command_palette/src/command_palette.rs@@ -557,7 +557,7 @@ mod tests {.clone()});- palette.update(cx, |palette, _| {+ palette.read_with(cx, |palette, _| {assert!(palette.delegate.commands.len() > 5);let is_sorted =|actions: &[Command]| actions.windows(2).all(|pair| pair[0].name <= pair[1].name);@@ -566,7 +566,7 @@ mod tests {cx.simulate_input("bcksp");- palette.update(cx, |palette, _| {+ palette.read_with(cx, |palette, _| {assert_eq!(palette.delegate.matches[0].string, "editor: backspace");});@@ -595,7 +595,7 @@ mod tests {.picker.clone()});- palette.update(cx, |palette, _| {+ palette.read_with(cx, |palette, _| {assert!(palette.delegate.matches.is_empty())});}@@ -630,7 +630,7 @@ mod tests {});cx.simulate_input("Editor:: Backspace");- palette.update(cx, |palette, _| {+ palette.read_with(cx, |palette, _| {assert_eq!(palette.delegate.matches[0].string, "editor: backspace");});}diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rsindex 60bf15eb5ff..c561ec38653 100644--- a/crates/copilot/src/copilot.rs+++ b/crates/copilot/src/copilot.rs@@ -232,7 +232,7 @@ impl RegisteredBuffer {Some(buffer.snapshot.version.clone())}).ok()??;- let new_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()).ok()?;+ let new_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot()).ok()?;let content_changes = cx.background_spawn({diff --git a/crates/debugger_ui/src/attach_modal.rs b/crates/debugger_ui/src/attach_modal.rsindex 0dda1345fa8..d4654501cd6 100644--- a/crates/debugger_ui/src/attach_modal.rs+++ b/crates/debugger_ui/src/attach_modal.rs@@ -158,7 +158,7 @@ impl PickerDelegate for AttachModalDelegate {) -> gpui::Task<()> {cx.spawn(async move |this, cx| {let Some(processes) = this- .update(cx, |this, _| this.delegate.candidates.clone())+ .read_with(cx, |this, _| this.delegate.candidates.clone()).ok()else {return;@@ -309,7 +309,7 @@ impl PickerDelegate for AttachModalDelegate {#[cfg(any(test, feature = "test-support"))]pub(crate) fn _process_names(modal: &AttachModal, cx: &mut Context<AttachModal>) -> Vec<String> {- modal.picker.update(cx, |picker, _| {+ modal.picker.read_with(cx, |picker, _| {picker.delegate.matchesdiff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rsindex 8fb006de747..1786dc93848 100644--- a/crates/debugger_ui/src/debugger_panel.rs+++ b/crates/debugger_ui/src/debugger_panel.rs@@ -955,7 +955,7 @@ impl DebugPanel {cx.spawn_in(window, async move |workspace, cx| {let serialized_scenario = serialized_scenario?;let fs =- workspace.update(cx, |workspace, _| workspace.app_state().fs.clone())?;+ workspace.read_with(cx, |workspace, _| workspace.app_state().fs.clone())?;path.push(paths::local_settings_folder_relative_path());if !fs.is_dir(path.as_path()).await {@@ -1014,7 +1014,7 @@ async fn register_session_inner(session: Entity<Session>,cx: &mut AsyncWindowContext,) -> Result<Entity<DebugSession>> {- let adapter_name = session.update(cx, |session, _| session.adapter())?;+ let adapter_name = session.read_with(cx, |session, _| session.adapter())?;this.update_in(cx, |_, window, cx| {cx.subscribe_in(&session,diff --git a/crates/debugger_ui/src/session/running.rs b/crates/debugger_ui/src/session/running.rsindex ea530f3c59d..bb081940ee4 100644--- a/crates/debugger_ui/src/session/running.rs+++ b/crates/debugger_ui/src/session/running.rs@@ -319,7 +319,7 @@ pub(crate) fn new_debugger_pane(if let Some(tab) = dragged_item.downcast_ref::<DraggedTab>() {let is_current_pane = tab.pane == cx.entity();let Some(can_drag_away) = weak_running- .update(cx, |running_state, _| {+ .read_with(cx, |running_state, _| {let current_panes = running_state.panes.panes();!current_panes.contains(&&tab.pane)|| current_panes.len() > 1@@ -952,7 +952,7 @@ impl RunningState {let running = cx.entity();let Ok(project) = self.workspace- .update(cx, |workspace, _| workspace.project().clone())+ .read_with(cx, |workspace, _| workspace.project().clone())else {return Task::ready(Err(anyhow!("no workspace")));};diff --git a/crates/debugger_ui/src/session/running/breakpoint_list.rs b/crates/debugger_ui/src/session/running/breakpoint_list.rsindex 1091c992ef5..3b63aa73cd7 100644--- a/crates/debugger_ui/src/session/running/breakpoint_list.rs+++ b/crates/debugger_ui/src/session/running/breakpoint_list.rs@@ -109,7 +109,7 @@ impl BreakpointList {.update(cx, |this, cx| this.find_or_create_worktree(path, false, cx));cx.spawn_in(window, async move |this, cx| {let (worktree, relative_path) = task.await?;- let worktree_id = worktree.update(cx, |this, _| this.id())?;+ let worktree_id = worktree.read_with(cx, |this, _| this.id())?;let item = this.update_in(cx, |this, window, cx| {this.workspace.update(cx, |this, cx| {diff --git a/crates/debugger_ui/src/session/running/stack_frame_list.rs b/crates/debugger_ui/src/session/running/stack_frame_list.rsindex 4c86be38756..5f524828a8c 100644--- a/crates/debugger_ui/src/session/running/stack_frame_list.rs+++ b/crates/debugger_ui/src/session/running/stack_frame_list.rs@@ -280,7 +280,7 @@ impl StackFrameList {})})??.await?;- let position = buffer.update(cx, |this, _| {+ let position = buffer.read_with(cx, |this, _| {this.snapshot().anchor_after(PointUtf16::new(row, 0))})?;this.update_in(cx, |this, window, cx| {diff --git a/crates/debugger_ui/src/stack_trace_view.rs b/crates/debugger_ui/src/stack_trace_view.rsindex 1f79899ff42..feb4bac8b2b 100644--- a/crates/debugger_ui/src/stack_trace_view.rs+++ b/crates/debugger_ui/src/stack_trace_view.rs@@ -148,7 +148,7 @@ impl StackTraceView {let stack_frames = self.stack_frame_list- .update(cx, |list, _| list.flatten_entries(false));+ .read_with(cx, |list, _| list.flatten_entries(false));let frames_to_open: Vec<_> = stack_frames.into_iter()@@ -237,7 +237,7 @@ impl StackTraceView {let stack_frames = self.stack_frame_list- .update(cx, |session, _| session.flatten_entries(false));+ .read_with(cx, |session, _| session.flatten_entries(false));let active_idx = self.selected_stack_frame_iddiff --git a/crates/diagnostics/src/diagnostic_renderer.rs b/crates/diagnostics/src/diagnostic_renderer.rsindex c8572ff37d5..9524f97ff1e 100644--- a/crates/diagnostics/src/diagnostic_renderer.rs+++ b/crates/diagnostics/src/diagnostic_renderer.rs@@ -256,7 +256,7 @@ impl DiagnosticBlock {if let Some(diagnostics_editor) = diagnostics_editor {if let Some(diagnostic) = diagnostics_editor- .update(cx, |diagnostics, _| {+ .read_with(cx, |diagnostics, _| {diagnostics.diagnostics.get(&buffer_id)diff --git a/crates/editor/src/clangd_ext.rs b/crates/editor/src/clangd_ext.rsindex 6062e7bc77b..b745bf8c37c 100644--- a/crates/editor/src/clangd_ext.rs+++ b/crates/editor/src/clangd_ext.rs@@ -39,12 +39,12 @@ pub fn switch_source_header(else {return Ok(());};- let source_file = buffer.update(cx, |buffer, _| {+ let source_file = buffer.read_with(cx, |buffer, _| {buffer.file().map(|file| file.path()).map(|path| path.to_string_lossy().to_string()).unwrap_or_else(|| "Unknown".to_string())})?;let switch_source_header = if let Some((client, project_id)) = upstream_client {- let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id())?;+ let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id())?;let request = proto::LspExtSwitchSourceHeader {project_id,buffer_id: buffer_id.to_proto(),diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 2b1bfb09ed5..bbdf792767d 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -14610,7 +14610,7 @@ impl Editor {let location = match location_task {Some(task) => Some({let target_buffer_handle = task.await.context("open local buffer")?;- let range = target_buffer_handle.update(cx, |target_buffer, _| {+ let range = target_buffer_handle.read_with(cx, |target_buffer, _| {let target_start = target_buffer.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);let target_end = target_buffer@@ -14799,7 +14799,7 @@ impl Editor {} else {if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {let (preview_item_id, preview_item_idx) =- workspace.active_pane().update(cx, |pane, _| {+ workspace.active_pane().read_with(cx, |pane, _| {(pane.preview_item_id(), pane.preview_item_idx())});@@ -20115,7 +20115,7 @@ impl SemanticsProvider for Entity<Project> {PrepareRenameResponse::InvalidPosition => None,PrepareRenameResponse::OnlyUnpreparedRenameSupported => {// Fallback on using TreeSitter info to determine identifier range- buffer.update(cx, |buffer, _| {+ buffer.read_with(cx, |buffer, _| {let snapshot = buffer.snapshot();let (range, kind) = snapshot.surrounding_word(position);if kind != Some(CharKind::Word) {diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 2a304dafe4e..8bd272372dd 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -2193,7 +2193,7 @@ impl EditorElement {) {let mouse_position = window.mouse_position();let mouse_over_inline_blame = parent_bounds.contains(&mouse_position);- let mouse_over_popover = self.editor.update(cx, |editor, _| {+ let mouse_over_popover = self.editor.read_with(cx, |editor, _| {editor.inline_blame_popover.as_ref()@@ -2209,7 +2209,7 @@ impl EditorElement {}});- let should_draw = self.editor.update(cx, |editor, _| {+ let should_draw = self.editor.read_with(cx, |editor, _| {editor.inline_blame_popover.as_ref()@@ -2243,7 +2243,7 @@ impl EditorElement {if let Some(mut element) = maybe_element {let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);- let origin = self.editor.update(cx, |editor, _| {+ let origin = self.editor.read_with(cx, |editor, _| {let target_point = editor.inline_blame_popover.as_ref()@@ -4322,7 +4322,7 @@ impl EditorElement {..Default::default()};window.with_text_style(Some(text_style), |window| {- let mut element = self.editor.update(cx, |editor, _| {+ let mut element = self.editor.read_with(cx, |editor, _| {let mouse_context_menu = editor.mouse_context_menu.as_ref()?;let context_menu = mouse_context_menu.context_menu.clone();diff --git a/crates/editor/src/git/blame.rs b/crates/editor/src/git/blame.rsindex fb718ed49b3..d4c9e378954 100644--- a/crates/editor/src/git/blame.rs+++ b/crates/editor/src/git/blame.rs@@ -786,7 +786,7 @@ mod tests {}).await.unwrap();- let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id());+ let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id());let git_blame = cx.new(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));@@ -896,7 +896,7 @@ mod tests {}).await.unwrap();- let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id());+ let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id());let git_blame = cx.new(|cx| GitBlame::new(buffer.clone(), project, false, true, cx));diff --git a/crates/editor/src/hover_links.rs b/crates/editor/src/hover_links.rsindex 73890589a93..927981e6e66 100644--- a/crates/editor/src/hover_links.rs+++ b/crates/editor/src/hover_links.rs@@ -539,7 +539,7 @@ pub fn show_link_definition(let result = match &trigger_point {TriggerPoint::Text(_) => {if let Some((url_range, url)) = find_url(&buffer, buffer_position, cx.clone()) {- this.update(cx, |_, _| {+ this.read_with(cx, |_, _| {let range = maybe!({let start =snapshot.anchor_in_excerpt(excerpt_id, url_range.start)?;@@ -665,7 +665,7 @@ pub(crate) fn find_url() -> Option<(Range<text::Anchor>, String)> {const LIMIT: usize = 2048;- let Ok(snapshot) = buffer.update(&mut cx, |buffer, _| buffer.snapshot()) else {+ let Ok(snapshot) = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot()) else {return None;};@@ -727,7 +727,7 @@ pub(crate) fn find_url_from_range() -> Option<String> {const LIMIT: usize = 2048;- let Ok(snapshot) = buffer.update(&mut cx, |buffer, _| buffer.snapshot()) else {+ let Ok(snapshot) = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot()) else {return None;};@@ -786,7 +786,7 @@ pub(crate) async fn find_file(cx: &mut AsyncWindowContext,) -> Option<(Range<text::Anchor>, ResolvedPath)> {let project = project?;- let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot()).ok()?;+ let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot()).ok()?;let scope = snapshot.language_scope_at(position);let (range, candidate_file_path) = surrounding_filename(snapshot, position)?;diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rsindex 5066c4365cc..d0288c5871f 100644--- a/crates/editor/src/hover_popover.rs+++ b/crates/editor/src/hover_popover.rs@@ -165,7 +165,7 @@ pub fn hover_at_inlay(this.hover_state.diagnostic_popover = None;})?;- let language_registry = project.update(cx, |p, _| p.languages().clone())?;+ let language_registry = project.read_with(cx, |p, _| p.languages().clone())?;let blocks = vec![inlay_hover.tooltip];let parsed_content = parse_blocks(&blocks, &language_registry, None, cx).await;diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rsindex 2ffe97c245e..dcfa8429a0d 100644--- a/crates/editor/src/inlay_hint_cache.rs+++ b/crates/editor/src/inlay_hint_cache.rs@@ -639,7 +639,7 @@ impl InlayHintCache {if let Some(resolved_hint_task) = resolved_hint_task {let mut resolved_hint =resolved_hint_task.await.context("hint resolve task")?;- editor.update(cx, |editor, _| {+ editor.read_with(cx, |editor, _| {if let Some(excerpt_hints) =editor.inlay_hint_cache.hints.get(&excerpt_id){@@ -933,7 +933,7 @@ fn fetch_and_update_hints(cx: &mut Context<Editor>,) -> Task<anyhow::Result<()>> {cx.spawn(async move |editor, cx|{- let buffer_snapshot = excerpt_buffer.update(cx, |buffer, _| buffer.snapshot())?;+ let buffer_snapshot = excerpt_buffer.read_with(cx, |buffer, _| buffer.snapshot())?;let (lsp_request_limiter, multi_buffer_snapshot) =editor.update(cx, |editor, cx| {let multi_buffer_snapshot =@@ -1009,7 +1009,7 @@ fn fetch_and_update_hints(.ok().flatten();- let cached_excerpt_hints = editor.update(cx, |editor, _| {+ let cached_excerpt_hints = editor.read_with(cx, |editor, _| {editor.inlay_hint_cache.hints@@ -2521,7 +2521,7 @@ pub mod tests {"Single buffer should produce a single excerpt with visible range");let (_, (excerpt_buffer, _, excerpt_visible_range)) = ranges.into_iter().next().unwrap();- excerpt_buffer.update(cx, |buffer, _| {+ excerpt_buffer.read_with(cx, |buffer, _| {let snapshot = buffer.snapshot();let start = buffer.anchor_before(excerpt_visible_range.start)diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rsindex a00405a249b..d822215949f 100644--- a/crates/editor/src/items.rs+++ b/crates/editor/src/items.rs@@ -841,7 +841,7 @@ impl Item for Editor {// so that language servers or other downstream listeners of save events get notified.let (dirty_buffers, clean_buffers) = buffers.into_iter().partition(|buffer| {buffer- .update(cx, |buffer, _| buffer.is_dirty() || buffer.has_conflict())+ .read_with(cx, |buffer, _| buffer.is_dirty() || buffer.has_conflict()).unwrap_or(false)});@@ -1089,7 +1089,7 @@ impl SerializableItem for Editor {let project = project.clone();async move |cx| {let language_registry =- project.update(cx, |project, _| project.languages().clone())?;+ project.read_with(cx, |project, _| project.languages().clone())?;let language = if let Some(language_name) = language {// We don't fail here, because we'd rather not set the language if the name changed@@ -2032,7 +2032,7 @@ mod tests {{let project = Project::test(fs.clone(), [path!("/file.rs").as_ref()], cx).await;// Add Rust to the language, so that we can restore the language of the buffer- project.update(cx, |project, _| project.languages().add(rust_language()));+ project.read_with(cx, |project, _| project.languages().add(rust_language()));let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));diff --git a/crates/editor/src/lsp_ext.rs b/crates/editor/src/lsp_ext.rsindex 6c22ba505e2..6dadbd0e499 100644--- a/crates/editor/src/lsp_ext.rs+++ b/crates/editor/src/lsp_ext.rs@@ -81,7 +81,7 @@ async fn lsp_task_context(cx: &mut AsyncApp,) -> Option<TaskContext> {let worktree_store = project- .update(cx, |project, _| project.worktree_store())+ .read_with(cx, |project, _| project.worktree_store()).ok()?;let worktree_abs_path = cxdiff --git a/crates/editor/src/rust_analyzer_ext.rs b/crates/editor/src/rust_analyzer_ext.rsindex ea2e7f41278..86153334fbe 100644--- a/crates/editor/src/rust_analyzer_ext.rs+++ b/crates/editor/src/rust_analyzer_ext.rs@@ -73,7 +73,7 @@ pub fn go_to_parent_module(};let location_links = if let Some((client, project_id)) = upstream_client {- let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id())?;+ let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id())?;let request = proto::LspExtGoToParentModule {project_id,@@ -95,7 +95,7 @@ pub fn go_to_parent_module(.collect::<anyhow::Result<_>>().context("go to parent module via collab")?} else {- let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot())?;+ let buffer_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);project.update(cx, |project, cx| {@@ -173,7 +173,7 @@ pub fn expand_macro_recursively(expansion: response.expansion,}} else {- let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot())?;+ let buffer_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);project.update(cx, |project, cx| {@@ -249,7 +249,7 @@ pub fn open_docs(editor: &mut Editor, _: &OpenDocs, window: &mut Window, cx: &mu};let docs_urls = if let Some((client, project_id)) = upstream_client {- let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id())?;+ let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id())?;let request = proto::LspExtOpenDocs {project_id,buffer_id: buffer_id.to_proto(),@@ -264,7 +264,7 @@ pub fn open_docs(editor: &mut Editor, _: &OpenDocs, window: &mut Window, cx: &mulocal: response.local,}} else {- let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot())?;+ let buffer_snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;let position = trigger_anchor.text_anchor.to_point_utf16(&buffer_snapshot);project.update(cx, |project, cx| {diff --git a/crates/eval/src/instance.rs b/crates/eval/src/instance.rsindex 6e20c66c18e..78326c0a699 100644--- a/crates/eval/src/instance.rs+++ b/crates/eval/src/instance.rs@@ -644,7 +644,7 @@ pub fn wait_for_lang_server(let (mut tx, mut rx) = mpsc::channel(1);let lsp_store = project- .update(cx, |project, _| project.lsp_store())+ .read_with(cx, |project, _| project.lsp_store()).unwrap();let has_lang_server = bufferdiff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rsindex 792d3087641..72cf23a3b6b 100644--- a/crates/extensions_ui/src/extensions_ui.rs+++ b/crates/extensions_ui/src/extensions_ui.rs@@ -447,9 +447,11 @@ impl ExtensionsPage {let extension_store = ExtensionStore::global(cx);- let dev_extensions = extension_store.update(cx, |store, _| {- store.dev_extensions().cloned().collect::<Vec<_>>()- });+ let dev_extensions = extension_store+ .read(cx)+ .dev_extensions()+ .cloned()+ .collect::<Vec<_>>();let remote_extensions = extension_store.update(cx, |store, cx| {store.fetch_extensions(search.as_deref(), provides_filter.as_ref(), cx)diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rsindex 5fb1724eb7d..e50cc82f1e1 100644--- a/crates/file_finder/src/file_finder.rs+++ b/crates/file_finder/src/file_finder.rs@@ -1036,7 +1036,7 @@ impl FileFinderDelegate {) -> Task<()> {cx.spawn_in(window, async move |picker, cx| {let Some(project) = picker- .update(cx, |picker, _| picker.delegate.project.clone())+ .read_with(cx, |picker, _| picker.delegate.project.clone()).log_err()else {return;diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rsindex c07a0c64dba..aaa69373636 100644--- a/crates/git_ui/src/branch_picker.rs+++ b/crates/git_ui/src/branch_picker.rs@@ -360,7 +360,7 @@ impl PickerDelegate for BranchListDelegate {}let current_branch = self.repo.as_ref().map(|repo| {- repo.update(cx, |repo, _| {+ repo.read_with(cx, |repo, _| {repo.branch.as_ref().map(|branch| branch.ref_name.clone())})});diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rsindex 43cc2283bc4..3b1d7c99a7a 100644--- a/crates/git_ui/src/git_panel.rs+++ b/crates/git_ui/src/git_panel.rs@@ -4851,7 +4851,7 @@ mod tests {cx.executor().run_until_parked();- let app_state = workspace.update(cx, |workspace, _| workspace.app_state().clone());+ let app_state = workspace.read_with(cx, |workspace, _| workspace.app_state().clone());let panel = cx.new_window_entity(|window, cx| {GitPanel::new(workspace.clone(), project.clone(), app_state, window, cx)});@@ -4862,7 +4862,7 @@ mod tests {cx.executor().advance_clock(2 * UPDATE_DEBOUNCE);handle.await;- let entries = panel.update(cx, |panel, _| panel.entries.clone());+ let entries = panel.read_with(cx, |panel, _| panel.entries.clone());pretty_assertions::assert_eq!(entries,[@@ -4937,7 +4937,7 @@ mod tests {});cx.executor().advance_clock(2 * UPDATE_DEBOUNCE);handle.await;- let entries = panel.update(cx, |panel, _| panel.entries.clone());+ let entries = panel.read_with(cx, |panel, _| panel.entries.clone());pretty_assertions::assert_eq!(entries,[diff --git a/crates/git_ui/src/picker_prompt.rs b/crates/git_ui/src/picker_prompt.rsindex 4faf24d1494..46be756bce1 100644--- a/crates/git_ui/src/picker_prompt.rs+++ b/crates/git_ui/src/picker_prompt.rs@@ -144,7 +144,7 @@ impl PickerDelegate for PickerPromptDelegate {cx: &mut Context<Picker<Self>>,) -> Task<()> {cx.spawn_in(window, async move |picker, cx| {- let candidates = picker.update(cx, |picker, _| {+ let candidates = picker.read_with(cx, |picker, _| {picker.delegate.all_optionsdiff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rsindex 5a10731bfd5..a8c4c786498 100644--- a/crates/git_ui/src/project_diff.rs+++ b/crates/git_ui/src/project_diff.rs@@ -1394,7 +1394,7 @@ mod tests {);cx.run_until_parked();- let editor = diff.update(cx, |diff, _| diff.editor.clone());+ let editor = diff.read_with(cx, |diff, _| diff.editor.clone());assert_state_with_diff(&editor,cx,@@ -1526,7 +1526,7 @@ mod tests {);cx.run_until_parked();- let diff_editor = diff.update(cx, |diff, _| diff.editor.clone());+ let diff_editor = diff.read_with(cx, |diff, _| diff.editor.clone());assert_state_with_diff(&diff_editor,@@ -1642,7 +1642,7 @@ mod tests {workspace.active_item_as::<ProjectDiff>(cx).unwrap()});cx.focus(&item);- let editor = item.update(cx, |item, _| item.editor.clone());+ let editor = item.read_with(cx, |item, _| item.editor.clone());let mut cx = EditorTestContext::for_editor_in(editor, cx).await;@@ -1756,7 +1756,7 @@ mod tests {workspace.active_item_as::<ProjectDiff>(cx).unwrap()});cx.focus(&item);- let editor = item.update(cx, |item, _| item.editor.clone());+ let editor = item.read_with(cx, |item, _| item.editor.clone());let mut cx = EditorTestContext::for_editor_in(editor, cx).await;diff --git a/crates/languages/src/css.rs b/crates/languages/src/css.rsindex f62206300ac..f2a94809a0e 100644--- a/crates/languages/src/css.rs+++ b/crates/languages/src/css.rs@@ -200,7 +200,7 @@ mod tests {.unindent();let buffer = cx.new(|cx| language::Buffer::local(text, cx).with_language(language, cx));- let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());+ let outline = buffer.read_with(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());assert_eq!(outline.itemsdiff --git a/crates/languages/src/typescript.rs b/crates/languages/src/typescript.rsindex d114b501785..e620eb7e7df 100644--- a/crates/languages/src/typescript.rs+++ b/crates/languages/src/typescript.rs@@ -596,7 +596,7 @@ mod tests {.unindent();let buffer = cx.new(|cx| language::Buffer::local(text, cx).with_language(language, cx));- let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());+ let outline = buffer.read_with(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());assert_eq!(outline.itemsdiff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rsindex 0f1c078b638..a680c922d94 100644--- a/crates/multi_buffer/src/multi_buffer.rs+++ b/crates/multi_buffer/src/multi_buffer.rs@@ -1575,7 +1575,7 @@ impl MultiBuffer {context_line_count: u32,cx: &mut Context<Self>,) -> (Vec<Range<Anchor>>, bool) {- let buffer_snapshot = buffer.update(cx, |buffer, _| buffer.snapshot());+ let buffer_snapshot = buffer.read(cx).snapshot();let excerpt_ranges = build_excerpt_ranges(ranges, context_line_count, &buffer_snapshot);let (new, counts) = Self::merge_excerpt_ranges(&excerpt_ranges);diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rsindex 89ff20aaba7..3fec1d616ab 100644--- a/crates/outline/src/outline.rs+++ b/crates/outline/src/outline.rs@@ -532,7 +532,7 @@ mod tests {outline_view: &Entity<Picker<OutlineViewDelegate>>,cx: &mut VisualTestContext,) -> Vec<String> {- outline_view.update(cx, |outline_view, _| {+ outline_view.read_with(cx, |outline_view, _| {let items = &outline_view.delegate.outline.items;outline_view.delegatediff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rsindex cfde0ce9fbb..f3b58a885c6 100644--- a/crates/outline_panel/src/outline_panel.rs+++ b/crates/outline_panel/src/outline_panel.rs@@ -865,7 +865,7 @@ impl OutlinePanel {fn serialize(&mut self, cx: &mut Context<Self>) {let Some(serialization_key) = self.workspace- .update(cx, |workspace, _| {+ .read_with(cx, |workspace, _| {OutlinePanel::serialization_key(workspace)}).ok()@@ -5642,7 +5642,7 @@ mod tests {.advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));cx.run_until_parked();- let active_editor = outline_panel.update(cx, |outline_panel, _| {+ let active_editor = outline_panel.read_with(cx, |outline_panel, _| {outline_panel.active_editor().expect("should have an active editor open")@@ -5737,7 +5737,7 @@ mod tests {cx.executor().advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));cx.run_until_parked();- let new_active_editor = outline_panel.update(cx, |outline_panel, _| {+ let new_active_editor = outline_panel.read_with(cx, |outline_panel, _| {outline_panel.active_editor().expect("should have an active editor open")diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rsindex a17e234da59..6c5ec8157e3 100644--- a/crates/project/src/buffer_store.rs+++ b/crates/project/src/buffer_store.rs@@ -1340,7 +1340,7 @@ impl BufferStore {mut cx: AsyncApp,) -> Result<proto::BufferSaved> {let buffer_id = BufferId::new(envelope.payload.buffer_id)?;- let (buffer, project_id) = this.update(&mut cx, |this, _| {+ let (buffer, project_id) = this.read_with(&mut cx, |this, _| {anyhow::Ok((this.get_existing(buffer_id)?,this.downstream_client@@ -1354,7 +1354,7 @@ impl BufferStore {buffer.wait_for_version(deserialize_version(&envelope.payload.version))})?.await?;- let buffer_id = buffer.update(&mut cx, |buffer, _| buffer.remote_id())?;+ let buffer_id = buffer.read_with(&mut cx, |buffer, _| buffer.remote_id())?;if let Some(new_path) = envelope.payload.new_path {let new_path = ProjectPath::from_proto(new_path);@@ -1367,7 +1367,7 @@ impl BufferStore {.await?;}- buffer.update(&mut cx, |buffer, _| proto::BufferSaved {+ buffer.read_with(&mut cx, |buffer, _| proto::BufferSaved {project_id,buffer_id: buffer_id.into(),version: serialize_version(buffer.saved_version()),@@ -1524,7 +1524,7 @@ impl BufferStore {};cx.spawn(async move |this, cx| {- let Some(buffer) = this.update(cx, |this, _| this.get(buffer_id))? else {+ let Some(buffer) = this.read_with(cx, |this, _| this.get(buffer_id))? else {return anyhow::Ok(());};diff --git a/crates/project/src/debugger/breakpoint_store.rs b/crates/project/src/debugger/breakpoint_store.rsindex 13e92d8d763..fbe8fd11f0e 100644--- a/crates/project/src/debugger/breakpoint_store.rs+++ b/crates/project/src/debugger/breakpoint_store.rs@@ -267,7 +267,7 @@ impl BreakpointStore {message: TypedEnvelope<proto::ToggleBreakpoint>,mut cx: AsyncApp,) -> Result<proto::Ack> {- let breakpoints = this.update(&mut cx, |this, _| this.breakpoint_store())?;+ let breakpoints = this.read_with(&mut cx, |this, _| this.breakpoint_store())?;let path = this.update(&mut cx, |this, cx| {this.project_path_for_absolute_path(message.payload.path.as_ref(), cx)@@ -803,7 +803,7 @@ impl BreakpointStore {log::error!("Todo: Serialized breakpoints which do not have buffer (yet)");continue;};- let snapshot = buffer.update(cx, |buffer, _| buffer.snapshot())?;+ let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;let mut breakpoints_for_file =this.update(cx, |_, cx| BreakpointsInFile::new(buffer, cx))?;diff --git a/crates/project/src/debugger/dap_store.rs b/crates/project/src/debugger/dap_store.rsindex d182af62966..622630227a4 100644--- a/crates/project/src/debugger/dap_store.rs+++ b/crates/project/src/debugger/dap_store.rs@@ -232,7 +232,7 @@ impl DapStore {cx.spawn(async move |_, cx| {let response = request.await?;let binary = DebugAdapterBinary::from_proto(response)?;- let mut ssh_command = ssh_client.update(cx, |ssh, _| {+ let mut ssh_command = ssh_client.read_with(cx, |ssh, _| {anyhow::Ok(SshCommand {arguments: ssh.ssh_args().context("SSH arguments not found")?,})@@ -609,7 +609,7 @@ impl DapStore {});}VariableLookupKind::Expression => {- let Ok(eval_task) = session.update(cx, |session, _| {+ let Ok(eval_task) = session.read_with(cx, |session, _| {session.mode.request_dap(EvaluateCommand {expression: inline_value_location.variable_name.clone(),frame_id: Some(stack_frame_id),@@ -752,7 +752,7 @@ impl DapStore {let this = this.clone();async move |cx| {while let Some(message) = rx.next().await {- this.update(cx, |this, _| {+ this.read_with(cx, |this, _| {if let Some((downstream, project_id)) = this.downstream_client.clone() {downstream.send(proto::LogToDebugConsole {diff --git a/crates/project/src/debugger/session.rs b/crates/project/src/debugger/session.rsindex 5b8a6fb32f6..815bc553d2c 100644--- a/crates/project/src/debugger/session.rs+++ b/crates/project/src/debugger/session.rs@@ -407,7 +407,7 @@ impl LocalMode {let configuration_sequence = cx.spawn({async move |cx| {let breakpoint_store =- dap_store.update(cx, |dap_store, _| dap_store.breakpoint_store().clone())?;+ dap_store.read_with(cx, |dap_store, _| dap_store.breakpoint_store().clone())?;initialized_rx.await?;let errors_by_path = cx.update(|cx| this.send_source_breakpoints(false, &breakpoint_store, cx))?diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rsindex 8c8d2e232f2..344c00b63fd 100644--- a/crates/project/src/git_store.rs+++ b/crates/project/src/git_store.rs@@ -2179,7 +2179,7 @@ impl GitStore {id: RepositoryId,cx: &mut AsyncApp,) -> Result<Entity<Repository>> {- this.update(cx, |this, _| {+ this.read_with(cx, |this, _| {this.repositories.get(&id).context("missing repository handle")@@ -4022,7 +4022,7 @@ impl Repository {bail!("not a local repository")};let (snapshot, events) = this- .update(&mut cx, |this, _| {+ .read_with(&mut cx, |this, _| {compute_snapshot(this.id,this.work_directory_abs_path.clone(),diff --git a/crates/project/src/git_store/conflict_set.rs b/crates/project/src/git_store/conflict_set.rsindex 89a898d950a..0c4ecb5a88f 100644--- a/crates/project/src/git_store/conflict_set.rs+++ b/crates/project/src/git_store/conflict_set.rs@@ -504,7 +504,8 @@ mod tests {events_tx.send(event.clone()).ok();})});- let conflicts_snapshot = conflict_set.update(cx, |conflict_set, _| conflict_set.snapshot());+ let conflicts_snapshot =+ conflict_set.read_with(cx, |conflict_set, _| conflict_set.snapshot());assert!(conflicts_snapshot.conflicts.is_empty());buffer.update(cx, |buffer, cx| {@@ -543,7 +544,7 @@ mod tests {assert_eq!(update.old_range, 0..0);assert_eq!(update.new_range, 0..1);- let conflict = conflict_set.update(cx, |conflict_set, _| {+ let conflict = conflict_set.read_with(cx, |conflict_set, _| {conflict_set.snapshot().conflicts[0].clone()});cx.update(|cx| {diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rsindex 628f11b3a92..00ab0cc94b1 100644--- a/crates/project/src/lsp_command.rs+++ b/crates/project/src/lsp_command.rs@@ -313,7 +313,7 @@ impl LspCommand for PrepareRename {_: LanguageServerId,mut cx: AsyncApp,) -> Result<PrepareRenameResponse> {- buffer.update(&mut cx, |buffer, _| match message {+ buffer.read_with(&mut cx, |buffer, _| match message {Some(lsp::PrepareRenameResponse::Range(range))| Some(lsp::PrepareRenameResponse::RangeWithPlaceholder { range, .. }) => {let Range { start, end } = range_from_lsp(range);@@ -365,7 +365,7 @@ impl LspCommand for PrepareRename {.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -513,7 +513,7 @@ impl LspCommand for PerformRename {})?.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,new_name: message.new_name,push_to_history: false,})@@ -625,7 +625,7 @@ impl LspCommand for GetDefinition {})?.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -724,7 +724,7 @@ impl LspCommand for GetDeclaration {})?.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -816,7 +816,7 @@ impl LspCommand for GetImplementation {})?.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -915,7 +915,7 @@ impl LspCommand for GetTypeDefinition {})?.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -1296,7 +1296,7 @@ impl LspCommand for GetReferences {target_buffer_handle.clone()- .update(&mut cx, |target_buffer, _| {+ .read_with(&mut cx, |target_buffer, _| {let target_start = target_buffer.clip_point_utf16(point_from_lsp(lsp_location.range.start), Bias::Left);let target_end = target_buffer@@ -1340,7 +1340,7 @@ impl LspCommand for GetReferences {})?.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -1449,7 +1449,7 @@ impl LspCommand for GetDocumentHighlights {_: LanguageServerId,mut cx: AsyncApp,) -> Result<Vec<DocumentHighlight>> {- buffer.update(&mut cx, |buffer, _| {+ buffer.read_with(&mut cx, |buffer, _| {let mut lsp_highlights = lsp_highlights.unwrap_or_default();lsp_highlights.sort_unstable_by_key(|h| (h.range.start, Reverse(h.range.end)));lsp_highlights@@ -1497,7 +1497,7 @@ impl LspCommand for GetDocumentHighlights {})?.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -1822,7 +1822,7 @@ impl LspCommand for GetSignatureHelp {})?.await.with_context(|| format!("waiting for version for buffer {}", buffer.entity_id()))?;- let buffer_snapshot = buffer.update(&mut cx, |buffer, _| buffer.snapshot())?;+ let buffer_snapshot = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot())?;Ok(Self {position: payload.position@@ -1906,7 +1906,7 @@ impl LspCommand for GetHover {return Ok(None);};- let (language, range) = buffer.update(&mut cx, |buffer, _| {+ let (language, range) = buffer.read_with(&mut cx, |buffer, _| {(buffer.language().cloned(),hover.range.map(|range| {@@ -1992,7 +1992,7 @@ impl LspCommand for GetHover {})?.await?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -2066,7 +2066,7 @@ impl LspCommand for GetHover {return Ok(None);}- let language = buffer.update(&mut cx, |buffer, _| buffer.language().cloned())?;+ let language = buffer.read_with(&mut cx, |buffer, _| buffer.language().cloned())?;let range = if let (Some(start), Some(end)) = (message.start, message.end) {language::proto::deserialize_anchor(start).and_then(|start| language::proto::deserialize_anchor(end).map(|end| start..end))@@ -2141,7 +2141,7 @@ impl LspCommand for GetCompletions {};let language_server_adapter = lsp_store- .update(&mut cx, |lsp_store, _| {+ .read_with(&mut cx, |lsp_store, _| {lsp_store.language_server_adapter_for_id(server_id)})?.with_context(|| format!("no language server with id {server_id}"))?;@@ -2317,7 +2317,7 @@ impl LspCommand for GetCompletions {.position.and_then(language::proto::deserialize_anchor).map(|p| {- buffer.update(&mut cx, |buffer, _| {+ buffer.read_with(&mut cx, |buffer, _| {buffer.clip_point_utf16(Unclipped(p.to_point_utf16(buffer)), Bias::Left)})})@@ -2773,7 +2773,7 @@ impl LspCommand for OnTypeFormatting {})?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,trigger: message.trigger.clone(),options,push_to_history: false,@@ -2826,7 +2826,7 @@ impl InlayHints {_ => None,});- let position = buffer_handle.update(cx, |buffer, _| {+ let position = buffer_handle.read_with(cx, |buffer, _| {let position = buffer.clip_point_utf16(point_from_lsp(lsp_hint.position), Bias::Left);if kind == Some(InlayHintKind::Parameter) {buffer.anchor_before(position)@@ -3387,7 +3387,7 @@ impl LspCommand for GetCodeLens {server_id: LanguageServerId,mut cx: AsyncApp,) -> anyhow::Result<Vec<CodeAction>> {- let snapshot = buffer.update(&mut cx, |buffer, _| buffer.snapshot())?;+ let snapshot = buffer.read_with(&mut cx, |buffer, _| buffer.snapshot())?;let language_server = cx.update(|cx| {lsp_store.read(cx)diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rsindex f8fdf0450be..fdf12e8f04b 100644--- a/crates/project/src/lsp_store.rs+++ b/crates/project/src/lsp_store.rs@@ -535,8 +535,8 @@ impl LocalLspStore {let this = this.clone();let mut cx = cx.clone();async move {- let Some(server) =- this.update(&mut cx, |this, _| this.language_server_for_id(server_id))?+ let Some(server) = this+ .read_with(&mut cx, |this, _| this.language_server_for_id(server_id))?else {return Ok(None);};@@ -600,7 +600,7 @@ impl LocalLspStore {}}"textDocument/rangeFormatting" => {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {if let Some(server) = this.language_server_for_id(server_id){let options = reg@@ -626,7 +626,7 @@ impl LocalLspStore {})??;}"textDocument/onTypeFormatting" => {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {if let Some(server) = this.language_server_for_id(server_id){let options = reg@@ -651,7 +651,7 @@ impl LocalLspStore {})??;}"textDocument/formatting" => {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {if let Some(server) = this.language_server_for_id(server_id){let options = reg@@ -680,7 +680,7 @@ impl LocalLspStore {// Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings.}"textDocument/rename" => {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {if let Some(server) = this.language_server_for_id(server_id){let options = reg@@ -734,7 +734,7 @@ impl LocalLspStore {// Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings.}"textDocument/rename" => {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {if let Some(server) = this.language_server_for_id(server_id){server.update_capabilities(|capabilities| {@@ -744,7 +744,7 @@ impl LocalLspStore {})?;}"textDocument/rangeFormatting" => {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {if let Some(server) = this.language_server_for_id(server_id){server.update_capabilities(|capabilities| {@@ -755,7 +755,7 @@ impl LocalLspStore {})?;}"textDocument/onTypeFormatting" => {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {if let Some(server) = this.language_server_for_id(server_id){server.update_capabilities(|capabilities| {@@ -766,7 +766,7 @@ impl LocalLspStore {})?;}"textDocument/formatting" => {- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {if let Some(server) = this.language_server_for_id(server_id){server.update_capabilities(|capabilities| {@@ -1954,7 +1954,7 @@ impl LocalLspStore {} else if matches!(range_formatting_provider, Some(p) if *p != OneOf::Left(false)) {let _timer = zlog::time!(logger => "format-range");let buffer_start = lsp::Position::new(0, 0);- let buffer_end = buffer.update(cx, |b, _| point_to_lsp(b.max_point_utf16()))?;+ let buffer_end = buffer.read_with(cx, |b, _| point_to_lsp(b.max_point_utf16()))?;language_server.request::<lsp::request::RangeFormatting>(lsp::DocumentRangeFormattingParams {text_document: text_document.clone(),@@ -2029,7 +2029,7 @@ impl LocalLspStore {let stdin = child.stdin.as_mut().context("failed to acquire stdin")?;let text = buffer.handle- .update(cx, |buffer, _| buffer.as_rope().clone())?;+ .read_with(cx, |buffer, _| buffer.as_rope().clone())?;for chunk in text.chunks() {stdin.write_all(chunk.as_bytes()).await?;}@@ -3038,7 +3038,7 @@ impl LocalLspStore {) -> Result<lsp::ApplyWorkspaceEditResponse> {let this = this.upgrade().context("project project closed")?;let language_server = this- .update(cx, |this, _| this.language_server_for_id(server_id))?+ .read_with(cx, |this, _| this.language_server_for_id(server_id))?.context("language server not found")?;let transaction = Self::deserialize_workspace_edit(this.clone(),@@ -3851,9 +3851,9 @@ impl LspStore {}fn on_buffer_added(&mut self, buffer: &Entity<Buffer>, cx: &mut Context<Self>) -> Result<()> {- buffer.update(cx, |buffer, _| {- buffer.set_language_registry(self.languages.clone())- });+ buffer+ .read(cx)+ .set_language_registry(self.languages.clone());cx.subscribe(buffer, |this, buffer, event, cx| {this.on_buffer_event(buffer, event, cx);@@ -4691,7 +4691,9 @@ impl LspStore {kind: kind.as_str().to_owned(),buffer_ids: buffers.iter()- .map(|buffer| buffer.update(cx, |buffer, _| buffer.remote_id().into()))+ .map(|buffer| {+ buffer.read_with(cx, |buffer, _| buffer.remote_id().into())+ }).collect::<Result<_>>()?,}).await@@ -6760,7 +6762,7 @@ impl LspStore {})})?.await?;- if worktree.update(cx, |worktree, _| worktree.is_local())? {+ if worktree.read_with(cx, |worktree, _| worktree.is_local())? {lsp_store.update(cx, |lsp_store, cx| {lsp_store.register_local_language_server(@@ -6772,7 +6774,7 @@ impl LspStore {}).ok();}- let worktree_root = worktree.update(cx, |worktree, _| worktree.abs_path())?;+ let worktree_root = worktree.read_with(cx, |worktree, _| worktree.abs_path())?;let relative_path = if let Some(known_path) = known_relative_path {known_path} else {@@ -6781,7 +6783,7 @@ impl LspStore {(worktree, relative_path)};let project_path = ProjectPath {- worktree_id: worktree.update(cx, |worktree, _| worktree.id())?,+ worktree_id: worktree.read_with(cx, |worktree, _| worktree.id())?,path: relative_path,};lsp_store@@ -6897,7 +6899,7 @@ impl LspStore {envelope: TypedEnvelope<proto::MultiLspQuery>,mut cx: AsyncApp,) -> Result<proto::MultiLspQueryResponse> {- let response_from_ssh = this.update(&mut cx, |this, _| {+ let response_from_ssh = this.read_with(&mut cx, |this, _| {let (upstream_client, project_id) = this.upstream_client()?;let mut payload = envelope.payload.clone();payload.project_id = project_id;@@ -6919,7 +6921,7 @@ impl LspStore {buffer.wait_for_version(version.clone())})?.await?;- let buffer_version = buffer.update(&mut cx, |buffer, _| buffer.version())?;+ let buffer_version = buffer.read_with(&mut cx, |buffer, _| buffer.version())?;match envelope.payload.strategy@@ -7188,7 +7190,7 @@ impl LspStore {})?.context("worktree not found")?;let (old_abs_path, new_abs_path) = {- let root_path = worktree.update(&mut cx, |this, _| this.abs_path())?;+ let root_path = worktree.read_with(&mut cx, |this, _| this.abs_path())?;let new_path = PathBuf::from_proto(envelope.payload.new_path.clone());(root_path.join(&old_path), root_path.join(&new_path))};@@ -7203,7 +7205,7 @@ impl LspStore {).await;let response = Worktree::handle_rename_entry(worktree, envelope.payload, cx.clone()).await;- this.update(&mut cx, |this, _| {+ this.read_with(&mut cx, |this, _| {this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);}).ok();@@ -7386,7 +7388,7 @@ impl LspStore {mut cx: AsyncApp,) -> Result<proto::Ack> {let server_id = LanguageServerId(envelope.payload.language_server_id as usize);- lsp_store.update(&mut cx, |lsp_store, _| {+ lsp_store.read_with(&mut cx, |lsp_store, _| {if let Some(server) = lsp_store.language_server_for_id(server_id) {server.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())@@ -7438,7 +7440,7 @@ impl LspStore {mut cx: AsyncApp,) -> Result<proto::Ack> {let server_id = LanguageServerId(envelope.payload.language_server_id as usize);- lsp_store.update(&mut cx, |lsp_store, _| {+ lsp_store.read_with(&mut cx, |lsp_store, _| {if let Some(server) = lsp_store.language_server_for_id(server_id) {server.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())@@ -8097,7 +8099,7 @@ impl LspStore {let peer_id = envelope.original_sender_id().unwrap_or_default();let symbol = envelope.payload.symbol.context("invalid symbol")?;let symbol = Self::deserialize_symbol(symbol)?;- let symbol = this.update(&mut cx, |this, _| {+ let symbol = this.read_with(&mut cx, |this, _| {let signature = this.symbol_signature(&symbol.path);anyhow::ensure!(signature == symbol.signature, "invalid symbol signature");Ok(symbol)@@ -8392,7 +8394,7 @@ impl LspStore {trigger: trigger as i32,buffer_ids: buffers.iter()- .map(|buffer| buffer.update(cx, |buffer, _| buffer.remote_id().into()))+ .map(|buffer| buffer.read_with(cx, |buffer, _| buffer.remote_id().into())).collect::<Result<_>>()?,}).awaitdiff --git a/crates/project/src/lsp_store/lsp_ext_command.rs b/crates/project/src/lsp_store/lsp_ext_command.rsindex c3f1e8b767f..4b7616d4d1e 100644--- a/crates/project/src/lsp_store/lsp_ext_command.rs+++ b/crates/project/src/lsp_store/lsp_ext_command.rs@@ -117,7 +117,7 @@ impl LspCommand for ExpandMacro {.and_then(deserialize_anchor).context("invalid position")?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -247,7 +247,7 @@ impl LspCommand for OpenDocs {.and_then(deserialize_anchor).context("invalid position")?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}@@ -452,7 +452,7 @@ impl LspCommand for GoToParentModule {.and_then(deserialize_anchor).context("bad request with bad position")?;Ok(Self {- position: buffer.update(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,+ position: buffer.read_with(&mut cx, |buffer, _| position.to_point_utf16(buffer))?,})}diff --git a/crates/project/src/lsp_store/rust_analyzer_ext.rs b/crates/project/src/lsp_store/rust_analyzer_ext.rsindex 901eeeee6e4..deea5d5dd70 100644--- a/crates/project/src/lsp_store/rust_analyzer_ext.rs+++ b/crates/project/src/lsp_store/rust_analyzer_ext.rs@@ -109,7 +109,7 @@ pub fn cancel_flycheck(else {return Ok(());};- let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id().to_proto())?;+ let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id().to_proto())?;if let Some((client, project_id)) = upstream_client {let request = proto::LspExtCancelFlycheck {@@ -123,7 +123,7 @@ pub fn cancel_flycheck(.context("lsp ext cancel flycheck proto request")?;} else {lsp_store- .update(cx, |lsp_store, _| {+ .read_with(cx, |lsp_store, _| {if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {server.notify::<lsp_store::lsp_ext_command::LspExtCancelFlycheck>(&())?;}@@ -160,7 +160,7 @@ pub fn run_flycheck(else {return Ok(());};- let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id().to_proto())?;+ let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id().to_proto())?;if let Some((client, project_id)) = upstream_client {let request = proto::LspExtRunFlycheck {@@ -175,7 +175,7 @@ pub fn run_flycheck(.context("lsp ext run flycheck proto request")?;} else {lsp_store- .update(cx, |lsp_store, _| {+ .read_with(cx, |lsp_store, _| {if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {server.notify::<lsp_store::lsp_ext_command::LspExtRunFlycheck>(&lsp_store::lsp_ext_command::RunFlycheckParams {@@ -216,7 +216,7 @@ pub fn clear_flycheck(else {return Ok(());};- let buffer_id = buffer.update(cx, |buffer, _| buffer.remote_id().to_proto())?;+ let buffer_id = buffer.read_with(cx, |buffer, _| buffer.remote_id().to_proto())?;if let Some((client, project_id)) = upstream_client {let request = proto::LspExtClearFlycheck {@@ -230,7 +230,7 @@ pub fn clear_flycheck(.context("lsp ext clear flycheck proto request")?;} else {lsp_store- .update(cx, |lsp_store, _| {+ .read_with(cx, |lsp_store, _| {if let Some(server) = lsp_store.language_server_for_id(rust_analyzer_server) {server.notify::<lsp_store::lsp_ext_command::LspExtClearFlycheck>(&())?;}diff --git a/crates/project/src/manifest_tree.rs b/crates/project/src/manifest_tree.rsindex 2104067a033..3fc37f37e46 100644--- a/crates/project/src/manifest_tree.rs+++ b/crates/project/src/manifest_tree.rs@@ -133,7 +133,7 @@ impl ManifestTree {};let key = TriePath::from(&*path);- worktree_roots.update(cx, |this, _| {+ worktree_roots.read_with(cx, |this, _| {this.roots.walk(&key, &mut |path, labels| {for (label, presence) in labels {if let Some((marked_path, current_presence)) = roots.get_mut(label) {diff --git a/crates/project/src/prettier_store.rs b/crates/project/src/prettier_store.rsindex 58cbd65923c..32cadd7ecf0 100644--- a/crates/project/src/prettier_store.rs+++ b/crates/project/src/prettier_store.rs@@ -279,7 +279,7 @@ impl PrettierStore {) -> PrettierTask {cx.spawn(async move |prettier_store, cx| {log::info!("Starting prettier at path {prettier_dir:?}");- let new_server_id = prettier_store.update(cx, |prettier_store, _| {+ let new_server_id = prettier_store.read_with(cx, |prettier_store, _| {prettier_store.languages.next_language_server_id()})?;@@ -306,7 +306,7 @@ impl PrettierStore {cx: &mut Context<PrettierStore>,) -> Task<anyhow::Result<PrettierTask>> {cx.spawn(async move |prettier_store, cx| {- let installation_task = prettier_store.update(cx, |prettier_store, _| {+ let installation_task = prettier_store.read_with(cx, |prettier_store, _| {match &prettier_store.default_prettier.prettier {PrettierInstallation::NotInstalled {installation_task, ..@@ -407,7 +407,7 @@ impl PrettierStore {.read(cx).worktree_for_id(id, cx)})- .map(|worktree| worktree.update(cx, |worktree, _| worktree.abs_path()));+ .map(|worktree| worktree.read(cx).abs_path());let name = match worktree_path {Some(worktree_path) => {if prettier_dir == worktree_path.as_ref() {diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex 06d91e5b2ad..22a53878a84 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -1540,7 +1540,7 @@ impl Project {.unwrap().await.unwrap();- tree.update(cx, |tree, _| tree.as_local().unwrap().scan_complete())+ tree.read_with(cx, |tree, _| tree.as_local().unwrap().scan_complete()).unwrap().await;}@@ -1579,7 +1579,7 @@ impl Project {.await.unwrap();- tree.update(cx, |tree, _| tree.as_local().unwrap().scan_complete())+ tree.read_with(cx, |tree, _| tree.as_local().unwrap().scan_complete()).await;}project@@ -1945,7 +1945,7 @@ impl Project {let lsp_store = self.lsp_store().downgrade();cx.spawn(async move |_, cx| {let (old_abs_path, new_abs_path) = {- let root_path = worktree.update(cx, |this, _| this.abs_path())?;+ let root_path = worktree.read_with(cx, |this, _| this.abs_path())?;let new_abs_path = if is_root_entry {root_path.parent().unwrap().join(&new_path)} else {@@ -1970,7 +1970,7 @@ impl Project {.await?;lsp_store- .update(cx, |this, _| {+ .read_with(cx, |this, _| {this.did_rename_entry(worktree_id, &old_abs_path, &new_abs_path, is_dir);}).ok();@@ -2550,7 +2550,7 @@ impl Project {cx: &mut AsyncApp,) -> Result<()> {for (buffer_id, operations) in operations_by_buffer_id.drain() {- let request = this.update(cx, |this, _| {+ let request = this.read_with(cx, |this, _| {let project_id = this.remote_id()?;Some(this.client.request(proto::UpdateBuffer {buffer_id: buffer_id.into(),@@ -2572,7 +2572,7 @@ impl Project {let mut changes = rx.ready_chunks(MAX_BATCH_SIZE);while let Some(changes) = changes.next().await {- let is_local = this.update(cx, |this, _| this.is_local())?;+ let is_local = this.read_with(cx, |this, _| this.is_local())?;for change in changes {match change {@@ -2614,7 +2614,7 @@ impl Project {).await?;- this.update(cx, |this, _| {+ this.read_with(cx, |this, _| {if let Some(project_id) = this.remote_id() {this.client.send(proto::UpdateLanguageServer {@@ -4007,7 +4007,7 @@ impl Project {cx: &mut AsyncApp,) -> Option<ResolvedPath> {worktree- .update(cx, |worktree, _| {+ .read_with(cx, |worktree, _| {let root_entry_path = &worktree.root_entry()?.path;let resolved = resolve_path(root_entry_path, path);let stripped = resolved.strip_prefix(root_entry_path).unwrap_or(&resolved);diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rsindex 16cfb3fbdab..4477b431a5b 100644--- a/crates/project/src/project_settings.rs+++ b/crates/project/src/project_settings.rs@@ -902,7 +902,7 @@ impl SettingsObserver {let user_tasks_content = cx.background_executor().block(user_tasks_file_rx.next());let weak_entry = cx.weak_entity();cx.spawn(async move |settings_observer, cx| {- let Ok(task_store) = settings_observer.update(cx, |settings_observer, _| {+ let Ok(task_store) = settings_observer.read_with(cx, |settings_observer, _| {settings_observer.task_store.clone()}) else {return;diff --git a/crates/project/src/task_store.rs b/crates/project/src/task_store.rsindex c5f3b4ab1c5..902c6254d33 100644--- a/crates/project/src/task_store.rs+++ b/crates/project/src/task_store.rs@@ -70,7 +70,7 @@ impl TaskStore {.payload.location.context("no location given for task context handling")?;- let (buffer_store, is_remote) = store.update(&mut cx, |store, _| {+ let (buffer_store, is_remote) = store.read_with(&mut cx, |store, _| {Ok(match store {TaskStore::Functional(state) => (state.buffer_store.clone(),diff --git a/crates/project/src/worktree_store.rs b/crates/project/src/worktree_store.rsindex c9a34a337ba..e7c0fe08667 100644--- a/crates/project/src/worktree_store.rs+++ b/crates/project/src/worktree_store.rs@@ -367,7 +367,7 @@ impl WorktreeStore {let handle_id = worktree.entity_id();cx.subscribe(worktree, |_, worktree, event, cx| {- let worktree_id = worktree.update(cx, |worktree, _| worktree.id());+ let worktree_id = worktree.read(cx).id();match event {worktree::Event::UpdatedEntries(changes) => {cx.emit(WorktreeStoreEvent::WorktreeUpdatedEntries(diff --git a/crates/project/src/yarn.rs b/crates/project/src/yarn.rsindex 52a35f3203c..b8174bbed00 100644--- a/crates/project/src/yarn.rs+++ b/crates/project/src/yarn.rs@@ -93,7 +93,7 @@ impl YarnPathStore {let zip_file: Arc<Path> = Arc::from(zip_file);cx.spawn(async move |this, cx| {let dir = this- .update(cx, |this, _| {+ .read_with(cx, |this, _| {this.temp_dirs.get(&zip_file).map(|temp| temp.path().to_owned())diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rsindex ccdf00b3d43..06baa3b1e43 100644--- a/crates/project_panel/src/project_panel.rs+++ b/crates/project_panel/src/project_panel.rs@@ -694,7 +694,7 @@ impl ProjectPanel {fn serialize(&mut self, cx: &mut Context<Self>) {let Some(serialization_key) = self.workspace- .update(cx, |workspace, _| {+ .read_with(cx, |workspace, _| {ProjectPanel::serialization_key(workspace)}).ok()@@ -3457,7 +3457,7 @@ impl ProjectPanel {.read(cx).repo_snapshots(cx);let worktree = self.project.read(cx).worktree_for_id(worktree_id, cx)?;- worktree.update(cx, |tree, _| {+ worktree.read_with(cx, |tree, _| {utils::ReversibleIterable::new(GitTraversal::new(&repo_snapshots, tree.entries(true, 0usize)),reverse_search,@@ -3492,16 +3492,17 @@ impl ProjectPanel {let worktree = self.project.read(cx)- .worktree_for_id(start.worktree_id, cx)?;+ .worktree_for_id(start.worktree_id, cx)?+ .read(cx);- let search = worktree.update(cx, |tree, _| {- let entry = tree.entry_for_id(start.entry_id)?;- let root_entry = tree.root_entry()?;- let tree_id = tree.id();+ let search = {+ let entry = worktree.entry_for_id(start.entry_id)?;+ let root_entry = worktree.root_entry()?;+ let tree_id = worktree.id();let mut first_iter = GitTraversal::new(&repo_snapshots,- tree.traverse_from_path(true, true, true, entry.path.as_ref()),+ worktree.traverse_from_path(true, true, true, entry.path.as_ref()),);if reverse_search {@@ -3515,7 +3516,8 @@ impl ProjectPanel {.find(|ele| predicate(*ele, tree_id)).map(|ele| ele.to_owned());- let second_iter = GitTraversal::new(&repo_snapshots, tree.entries(true, 0usize));+ let second_iter =+ GitTraversal::new(&repo_snapshots, worktree.entries(true, 0usize));let second = if reverse_search {second_iter@@ -3536,7 +3538,7 @@ impl ProjectPanel {} else {Some((first, second))}- });+ };if let Some((first, second)) = search {let first = first.map(|entry| SelectedEntry {diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rsindex f47eadef43e..704123d2b37 100644--- a/crates/project_symbols/src/project_symbols.rs+++ b/crates/project_symbols/src/project_symbols.rs@@ -381,7 +381,7 @@ mod tests {});cx.run_until_parked();- symbols.update(cx, |symbols, _| {+ symbols.read_with(cx, |symbols, _| {assert_eq!(symbols.delegate.matches.len(), 0);});@@ -392,7 +392,7 @@ mod tests {});cx.run_until_parked();- symbols.update(cx, |symbols, _| {+ symbols.read_with(cx, |symbols, _| {let delegate = &symbols.delegate;assert_eq!(delegate.matches.len(), 2);assert_eq!(delegate.matches[0].string, "ton");@@ -406,7 +406,7 @@ mod tests {});cx.run_until_parked();- symbols.update(cx, |symbols, _| {+ symbols.read_with(cx, |symbols, _| {assert_eq!(symbols.delegate.matches.len(), 0);});}diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rsindex d2c985946f0..e1b8032fcea 100644--- a/crates/recent_projects/src/remote_servers.rs+++ b/crates/recent_projects/src/remote_servers.rs@@ -176,7 +176,7 @@ impl ProjectPicker {};let app_state = workspace- .update(cx, |workspace, _| workspace.app_state().clone())+ .read_with(cx, |workspace, _| workspace.app_state().clone()).ok()?;cx.update(|_, cx| {@@ -856,7 +856,7 @@ impl RemoteServerProjects {move |this: &mut Self, window: &mut Window, cx: &mut Context<Self>| {let Some(app_state) = this.workspace- .update(cx, |workspace, _| workspace.app_state().clone())+ .read_with(cx, |workspace, _| workspace.app_state().clone()).log_err()else {return;@@ -940,7 +940,7 @@ impl RemoteServerProjects {) {let Some(fs) = self.workspace- .update(cx, |workspace, _| workspace.app_state().fs.clone())+ .read_with(cx, |workspace, _| workspace.app_state().fs.clone()).log_err()else {return;diff --git a/crates/remote/src/ssh_session.rs b/crates/remote/src/ssh_session.rsindex 48ffb3000a9..d81816823d4 100644--- a/crates/remote/src/ssh_session.rs+++ b/crates/remote/src/ssh_session.rs@@ -901,7 +901,7 @@ impl SshRemoteClient {mut connection_activity_rx: mpsc::Receiver<()>,cx: &mut AsyncApp,) -> Task<Result<()>> {- let Ok(client) = this.update(cx, |this, _| this.client.clone()) else {+ let Ok(client) = this.read_with(cx, |this, _| this.client.clone()) else {return Task::ready(Err(anyhow!("SshRemoteClient lost")));};diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rsindex 58cdbda3990..44ae3a003d6 100644--- a/crates/remote_server/src/headless_project.rs+++ b/crates/remote_server/src/headless_project.rs@@ -383,7 +383,7 @@ impl HeadlessProject {};let worktree = this- .update(&mut cx.clone(), |this, _| {+ .read_with(&mut cx.clone(), |this, _| {Worktree::local(Arc::from(canonicalized.as_path()),message.payload.visible,@@ -394,11 +394,12 @@ impl HeadlessProject {})?.await?;- let response = this.update(&mut cx, |_, cx| {- worktree.update(cx, |worktree, _| proto::AddWorktreeResponse {+ let response = this.read_with(&mut cx, |_, cx| {+ let worktree = worktree.read(cx);+ proto::AddWorktreeResponse {worktree_id: worktree.id().to_proto(),canonicalized_path: canonicalized.to_proto(),- })+ }})?;// We spawn this asynchronously, so that we can send the response back@@ -572,7 +573,7 @@ impl HeadlessProject {let buffer_store = this.read_with(&cx, |this, _| this.buffer_store.clone())?;while let Ok(buffer) = results.recv().await {- let buffer_id = buffer.update(&mut cx, |this, _| this.remote_id())?;+ let buffer_id = buffer.read_with(&mut cx, |this, _| this.remote_id())?;response.buffer_ids.push(buffer_id.to_proto());buffer_store.update(&mut cx, |buffer_store, cx| {diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex 18b5cde0568..d1b4d7518ad 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -696,9 +696,9 @@ impl BufferSearchBar {.read(cx).as_singleton().expect("query editor should be backed by a singleton buffer");- query_buffer.update(cx, |query_buffer, _| {- query_buffer.set_language_registry(languages.clone());- });+ query_buffer+ .read(cx)+ .set_language_registry(languages.clone());cx.spawn(async move |buffer_search_bar, cx| {let regex_language = languages@@ -1692,7 +1692,7 @@ mod tests {[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(0));});@@ -1703,7 +1703,7 @@ mod tests {[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(1));});@@ -1714,7 +1714,7 @@ mod tests {[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(2));});@@ -1725,7 +1725,7 @@ mod tests {[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(0));});@@ -1736,7 +1736,7 @@ mod tests {[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(2));});@@ -1747,7 +1747,7 @@ mod tests {[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(1));});@@ -1758,7 +1758,7 @@ mod tests {[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(0));});@@ -1779,7 +1779,7 @@ mod tests {[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(0));});@@ -1800,7 +1800,7 @@ mod tests {[DisplayPoint::new(DisplayRow(3), 11)..DisplayPoint::new(DisplayRow(3), 13)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(1));});@@ -1821,7 +1821,7 @@ mod tests {[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(2));});@@ -1842,7 +1842,7 @@ mod tests {[DisplayPoint::new(DisplayRow(0), 41)..DisplayPoint::new(DisplayRow(0), 43)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(0));});@@ -1863,7 +1863,7 @@ mod tests {[DisplayPoint::new(DisplayRow(3), 56)..DisplayPoint::new(DisplayRow(3), 58)]);});- search_bar.update(cx, |search_bar, _| {+ search_bar.read_with(cx, |search_bar, _| {assert_eq!(search_bar.active_match_index, Some(2));});}diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rsindex bbf61559b6d..55a24dda6b6 100644--- a/crates/search/src/project_search.rs+++ b/crates/search/src/project_search.rs@@ -4019,7 +4019,7 @@ pub mod tests {window.update(cx, |workspace, window, cx| {assert_eq!(workspace.active_pane(), &first_pane);- first_pane.update(cx, |this, _| {+ first_pane.read_with(cx, |this, _| {assert_eq!(this.active_item_index(), 1);assert_eq!(this.items_len(), 2);});@@ -4203,7 +4203,7 @@ pub mod tests {});cx.run_until_parked();let project_search_view = pane- .update(&mut cx, |pane, _| {+ .read_with(&mut cx, |pane, _| {pane.active_item().and_then(|item| item.downcast::<ProjectSearchView>())})diff --git a/crates/snippet_provider/src/lib.rs b/crates/snippet_provider/src/lib.rsindex 045d51350f2..d1112a8d00f 100644--- a/crates/snippet_provider/src/lib.rs+++ b/crates/snippet_provider/src/lib.rs@@ -69,7 +69,7 @@ async fn process_updates(entries: Vec<PathBuf>,mut cx: AsyncApp,) -> Result<()> {- let fs = this.update(&mut cx, |this, _| this.fs.clone())?;+ let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;for entry_path in entries {if !entry_path.extension()@@ -120,7 +120,7 @@ async fn initial_scan(path: Arc<Path>,mut cx: AsyncApp,) -> Result<()> {- let fs = this.update(&mut cx, |this, _| this.fs.clone())?;+ let fs = this.read_with(&mut cx, |this, _| this.fs.clone())?;let entries = fs.read_dir(&path).await;if let Ok(entries) = entries {let entries = entries@@ -183,7 +183,7 @@ impl SnippetProvider {let path: Arc<Path> = Arc::from(path);self.watch_tasks.push(cx.spawn(async move |this, cx| {- let fs = this.update(cx, |this, _| this.fs.clone())?;+ let fs = this.read_with(cx, |this, _| this.fs.clone())?;let watched_path = path.clone();let watcher = fs.watch(&watched_path, Duration::from_secs(1));initial_scan(this.clone(), path, cx.clone()).await?;diff --git a/crates/tasks_ui/src/modal.rs b/crates/tasks_ui/src/modal.rsindex ece3ba78d4e..249b24c290d 100644--- a/crates/tasks_ui/src/modal.rs+++ b/crates/tasks_ui/src/modal.rs@@ -1176,7 +1176,7 @@ mod tests {scheduled_task_label: &str,cx: &mut VisualTestContext,) {- let scheduled_task = tasks_picker.update(cx, |tasks_picker, _| {+ let scheduled_task = tasks_picker.read_with(cx, |tasks_picker, _| {tasks_picker.delegate.candidates@@ -1220,14 +1220,14 @@ mod tests {spawn_tasks: &Entity<Picker<TasksModalDelegate>>,cx: &mut VisualTestContext,) -> String {- spawn_tasks.update(cx, |spawn_tasks, cx| spawn_tasks.query(cx))+ spawn_tasks.read_with(cx, |spawn_tasks, cx| spawn_tasks.query(cx))}fn task_names(spawn_tasks: &Entity<Picker<TasksModalDelegate>>,cx: &mut VisualTestContext,) -> Vec<String> {- spawn_tasks.update(cx, |spawn_tasks, _| {+ spawn_tasks.read_with(cx, |spawn_tasks, _| {spawn_tasks.delegate.matchesdiff --git a/crates/tasks_ui/src/tasks_ui.rs b/crates/tasks_ui/src/tasks_ui.rsindex 7e976184c0a..94e63d833ff 100644--- a/crates/tasks_ui/src/tasks_ui.rs+++ b/crates/tasks_ui/src/tasks_ui.rs@@ -300,9 +300,12 @@ pub fn task_contexts(.unwrap_or_default();let latest_selection = active_editor.as_ref().map(|active_editor| {- active_editor.update(cx, |editor, _| {- editor.selections.newest_anchor().head().text_anchor- })+ active_editor+ .read(cx)+ .selections+ .newest_anchor()+ .head()+ .text_anchor});let mut worktree_abs_paths = workspace@@ -412,7 +415,7 @@ mod tests {).await;let project = Project::test(fs, [path!("/dir").as_ref()], cx).await;- let worktree_store = project.update(cx, |project, _| project.worktree_store().clone());+ let worktree_store = project.read_with(cx, |project, _| project.worktree_store().clone());let rust_language = Arc::new(Language::new(LanguageConfig::default(),diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rsindex f6964abf059..a67ef707df2 100644--- a/crates/terminal_view/src/terminal_panel.rs+++ b/crates/terminal_view/src/terminal_panel.rs@@ -702,7 +702,7 @@ impl TerminalPanel {terminal_panel.pending_terminals_to_add += 1;terminal_panel.active_pane.clone()})?;- let project = workspace.update(cx, |workspace, _| workspace.project().clone())?;+ let project = workspace.read_with(cx, |workspace, _| workspace.project().clone())?;let window_handle = cx.window_handle();let terminal = project.update(cx, |project, cx| {@@ -754,7 +754,7 @@ impl TerminalPanel {let width = self.width;let Some(serialization_key) = self.workspace- .update(cx, |workspace, _| {+ .read_with(cx, |workspace, _| {TerminalPanel::serialization_key(workspace)}).ok()@@ -972,7 +972,7 @@ pub fn new_terminal_pane(if let Some(tab) = dragged_item.downcast_ref::<DraggedTab>() {let is_current_pane = tab.pane == cx.entity();let Some(can_drag_away) = split_closure_terminal_panel- .update(cx, |terminal_panel, _| {+ .read_with(cx, |terminal_panel, _| {let current_panes = terminal_panel.center.panes();!current_panes.contains(&&tab.pane)|| current_panes.len() > 1diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rsindex e0d6b3d56fd..af1466a1a25 100644--- a/crates/terminal_view/src/terminal_view.rs+++ b/crates/terminal_view/src/terminal_view.rs@@ -389,11 +389,9 @@ impl TerminalView {fn rerun_task(&mut self, _: &RerunTask, window: &mut Window, cx: &mut Context<Self>) {let task = self.terminal- .update(cx, |terminal, _| {- terminal- .task()- .map(|task| terminal_rerun_override(&task.id))- })+ .read(cx)+ .task()+ .map(|task| terminal_rerun_override(&task.id)).unwrap_or_default();window.dispatch_action(Box::new(task), cx);}diff --git a/crates/toolchain_selector/src/active_toolchain.rs b/crates/toolchain_selector/src/active_toolchain.rsindex 847bcc869fd..05370f64a22 100644--- a/crates/toolchain_selector/src/active_toolchain.rs+++ b/crates/toolchain_selector/src/active_toolchain.rs@@ -56,16 +56,16 @@ impl ActiveToolchain {fn spawn_tracker_task(window: &mut Window, cx: &mut Context<Self>) -> Task<Option<()>> {cx.spawn_in(window, async move |this, cx| {let active_file = this- .update(cx, |this, _| {+ .read_with(cx, |this, _| {this.active_buffer.as_ref().map(|(_, buffer, _)| buffer.clone())}).ok().flatten()?;- let workspace = this.update(cx, |this, _| this.workspace.clone()).ok()?;+ let workspace = this.read_with(cx, |this, _| this.workspace.clone()).ok()?;let language_name = active_file- .update(cx, |this, _| Some(this.language()?.name()))+ .read_with(cx, |this, _| Some(this.language()?.name())).ok().flatten()?;let term = workspace@@ -136,7 +136,7 @@ impl ActiveToolchain {) -> Task<Option<Toolchain>> {cx.spawn(async move |cx| {let workspace_id = workspace- .update(cx, |this, _| this.database_id())+ .read_with(cx, |this, _| this.database_id()).ok().flatten()?;let selected_toolchain = workspace@@ -156,7 +156,7 @@ impl ActiveToolchain {Some(toolchain)} else {let project = workspace- .update(cx, |this, _| this.project().clone())+ .read_with(cx, |this, _| this.project().clone()).ok()?;let toolchains = cx.update(|_, cx| {diff --git a/crates/toolchain_selector/src/toolchain_selector.rs b/crates/toolchain_selector/src/toolchain_selector.rsindex 67252dd6a48..5a19b6a0b30 100644--- a/crates/toolchain_selector/src/toolchain_selector.rs+++ b/crates/toolchain_selector/src/toolchain_selector.rs@@ -164,13 +164,13 @@ impl ToolchainSelectorDelegate {let project = project.clone();async move |this, cx| {let term = project- .update(cx, |this, _| {+ .read_with(cx, |this, _| {Project::toolchain_term(this.languages().clone(), language_name.clone())}).ok()?.await?;let relative_path = this- .update(cx, |this, _| this.delegate.relative_path.clone())+ .read_with(cx, |this, _| this.delegate.relative_path.clone()).ok()?;let placeholder_text = format!("Select a {} for `{}`…",@@ -257,7 +257,7 @@ impl PickerDelegate for ToolchainSelectorDelegate {let toolchain = self.candidates.toolchains[string_match.candidate_id].clone();if let Some(workspace_id) = self.workspace- .update(cx, |this, _| this.database_id())+ .read_with(cx, |this, _| this.database_id()).ok().flatten(){diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex 948ef024640..6c3e83df8fc 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -1762,7 +1762,7 @@ impl Pane {return Ok(true);}let Some(item_ix) = pane- .update(cx, |pane, _| pane.index_for_item(item))+ .read_with(cx, |pane, _| pane.index_for_item(item)).ok().flatten()else {@@ -2017,7 +2017,8 @@ impl Pane {let pane = cx.entity().clone();window.defer(cx, move |window, cx| {- let Ok(status_bar) = workspace.update(cx, |workspace, _| workspace.status_bar.clone())+ let Ok(status_bar) =+ workspace.read_with(cx, |workspace, _| workspace.status_bar.clone())else {return;};@@ -3760,7 +3761,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());pane.update_in(cx, |pane, window, cx| {assert!(@@ -3785,7 +3786,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());for i in 0..7 {add_labeled_item(&pane, format!("{}", i).as_str(), false, cx);@@ -3834,7 +3835,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());// 1. Add with a destination index// a. Add before the active item@@ -3917,7 +3918,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());// 1. Add with a destination index// 1a. Add before the active item@@ -3993,7 +3994,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());// singleton viewpane.update_in(cx, |pane, window, cx| {@@ -4098,7 +4099,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());add_labeled_item(&pane, "A", false, cx);add_labeled_item(&pane, "B", false, cx);@@ -4191,7 +4192,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());add_labeled_item(&pane, "A", false, cx);add_labeled_item(&pane, "B", false, cx);@@ -4284,7 +4285,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());add_labeled_item(&pane, "A", false, cx);add_labeled_item(&pane, "B", false, cx);@@ -4377,7 +4378,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);@@ -4405,7 +4406,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());add_labeled_item(&pane, "A", true, cx);add_labeled_item(&pane, "B", false, cx);@@ -4437,7 +4438,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);@@ -4464,7 +4465,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());set_labeled_items(&pane, ["A", "B", "C*", "D", "E"], cx);@@ -4491,7 +4492,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let item_a = add_labeled_item(&pane, "A", false, cx);add_labeled_item(&pane, "B", false, cx);@@ -4596,7 +4597,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let a = cx.update(|_, cx| TestProjectItem::new_dirty(1, "A.txt", cx));let b = cx.update(|_, cx| TestProjectItem::new_dirty(1, "B.txt", cx));@@ -4640,7 +4641,7 @@ mod tests {let project = Project::test(fs, None, cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let item_a = add_labeled_item(&pane, "A", false, cx);add_labeled_item(&pane, "B", false, cx);@@ -4674,7 +4675,7 @@ mod tests {cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));// Non-pinned tabs in same pane- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());add_labeled_item(&pane, "A", false, cx);add_labeled_item(&pane, "B", false, cx);add_labeled_item(&pane, "C", false, cx);@@ -4705,7 +4706,7 @@ mod tests {cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));// No non-pinned tabs in same pane, non-pinned tabs in another pane- let pane1 = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane1 = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let pane2 = workspace.update_in(cx, |workspace, window, cx| {workspace.split_pane(pane1.clone(), SplitDirection::Right, window, cx)});diff --git a/crates/workspace/src/persistence/model.rs b/crates/workspace/src/persistence/model.rsindex da006426753..4a6b9ccdf45 100644--- a/crates/workspace/src/persistence/model.rs+++ b/crates/workspace/src/persistence/model.rs@@ -410,7 +410,10 @@ impl SerializedPaneGroup {.await.log_err()?;- if pane.update(cx, |pane, _| pane.items_len() != 0).log_err()? {+ if pane+ .read_with(cx, |pane, _| pane.items_len() != 0)+ .log_err()?+ {let pane = pane.upgrade()?;Some((Member::Pane(pane.clone()),diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 8b1fcfdc133..0c989884c2a 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -2519,7 +2519,7 @@ impl Workspace {});cx.spawn(async move |cx| {let (worktree, path) = entry.await?;- let worktree_id = worktree.update(cx, |t, _| t.id())?;+ let worktree_id = worktree.read_with(cx, |t, _| t.id())?;Ok((worktree,ProjectPath {@@ -5147,7 +5147,7 @@ impl Workspace {cx: &mut Context<Workspace>,) -> Task<Result<Vec<Option<Box<dyn ItemHandle>>>>> {cx.spawn_in(window, async move |workspace, cx| {- let project = workspace.update(cx, |workspace, _| workspace.project().clone())?;+ let project = workspace.read_with(cx, |workspace, _| workspace.project().clone())?;let mut center_group = None;let mut center_items = None;@@ -6836,7 +6836,7 @@ pub fn create_and_open_local_file(default_content: impl 'static + Send + FnOnce() -> Rope,) -> Task<Result<Box<dyn ItemHandle>>> {cx.spawn_in(window, async move |workspace, cx| {- let fs = workspace.update(cx, |workspace, _| workspace.app_state().fs.clone())?;+ let fs = workspace.read_with(cx, |workspace, _| workspace.app_state().fs.clone())?;if !fs.is_file(path).await {fs.create_file(path, Default::default()).await?;fs.save(path, &default_content(), Default::default())@@ -7647,7 +7647,7 @@ mod tests {workspace.update_in(cx, |workspace, window, cx| {workspace.add_item_to_active_pane(Box::new(item1.clone()), None, true, window, cx);});- item1.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(0)));+ item1.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(0)));// Adding an item that creates ambiguity increases the level of detail on// both tabs.@@ -7659,8 +7659,8 @@ mod tests {workspace.update_in(cx, |workspace, window, cx| {workspace.add_item_to_active_pane(Box::new(item2.clone()), None, true, window, cx);});- item1.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));- item2.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));+ item1.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));+ item2.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));// Adding an item that creates ambiguity increases the level of detail only// on the ambiguous tabs. In this case, the ambiguity can't be resolved so@@ -7673,9 +7673,9 @@ mod tests {workspace.update_in(cx, |workspace, window, cx| {workspace.add_item_to_active_pane(Box::new(item3.clone()), None, true, window, cx);});- item1.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));- item2.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(3)));- item3.update(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(3)));+ item1.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(1)));+ item2.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(3)));+ item3.read_with(cx, |item, _| assert_eq!(item.tab_detail.get(), Some(3)));}#[gpui::test]@@ -7702,7 +7702,7 @@ mod tests {let project = Project::test(fs, ["root1".as_ref()], cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let worktree_id = project.update(cx, |project, cx| {project.worktrees(cx).next().unwrap().read(cx).id()});@@ -8099,7 +8099,7 @@ mod tests {cx.executor().run_until_parked();close.await.unwrap();- right_pane.update(cx, |pane, _| {+ right_pane.read_with(cx, |pane, _| {assert_eq!(pane.items_len(), 0);});}@@ -8112,7 +8112,7 @@ mod tests {let project = Project::test(fs, [], cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let item = cx.new(|cx| {TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])@@ -8134,12 +8134,12 @@ mod tests {// Deactivating the window saves the file.cx.deactivate_window();- item.update(cx, |item, _| assert_eq!(item.save_count, 1));+ item.read_with(cx, |item, _| assert_eq!(item.save_count, 1));// Re-activating the window doesn't save the file.cx.update(|window, _| window.activate_window());cx.executor().run_until_parked();- item.update(cx, |item, _| assert_eq!(item.save_count, 1));+ item.read_with(cx, |item, _| assert_eq!(item.save_count, 1));// Autosave on focus change.item.update_in(cx, |item, window, cx| {@@ -8155,7 +8155,7 @@ mod tests {// Blurring the item saves the file.item.update_in(cx, |_, window, _| window.blur());cx.executor().run_until_parked();- item.update(cx, |item, _| assert_eq!(item.save_count, 2));+ item.read_with(cx, |item, _| assert_eq!(item.save_count, 2));// Deactivating the window still saves the file.item.update_in(cx, |item, window, cx| {@@ -8178,11 +8178,11 @@ mod tests {// Delay hasn't fully expired, so the file is still dirty and unsaved.cx.executor().advance_clock(Duration::from_millis(250));- item.update(cx, |item, _| assert_eq!(item.save_count, 3));+ item.read_with(cx, |item, _| assert_eq!(item.save_count, 3));// After delay expires, the file is saved.cx.executor().advance_clock(Duration::from_millis(250));- item.update(cx, |item, _| assert_eq!(item.save_count, 4));+ item.read_with(cx, |item, _| assert_eq!(item.save_count, 4));// Autosave on focus change, ensuring closing the tab counts as such.item.update(cx, |item, cx| {@@ -8203,7 +8203,7 @@ mod tests {.await.unwrap();assert!(!cx.has_pending_prompt());- item.update(cx, |item, _| assert_eq!(item.save_count, 5));+ item.read_with(cx, |item, _| assert_eq!(item.save_count, 5));// Add the item again, ensuring autosave is prevented if the underlying file has been deleted.workspace.update_in(cx, |workspace, window, cx| {@@ -8217,7 +8217,7 @@ mod tests {window.blur();});cx.run_until_parked();- item.update(cx, |item, _| assert_eq!(item.save_count, 5));+ item.read_with(cx, |item, _| assert_eq!(item.save_count, 5));// Ensure autosave is prevented for deleted files also when closing the buffer.let _close_items = pane.update_in(cx, |pane, window, cx| {@@ -8225,7 +8225,7 @@ mod tests {});cx.run_until_parked();assert!(cx.has_pending_prompt());- item.update(cx, |item, _| assert_eq!(item.save_count, 5));+ item.read_with(cx, |item, _| assert_eq!(item.save_count, 5));}#[gpui::test]@@ -8241,8 +8241,8 @@ mod tests {let item = cx.new(|cx| {TestItem::new(cx).with_project_items(&[TestProjectItem::new(1, "1.txt", cx)])});- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());- let toolbar = pane.update(cx, |pane, _| pane.toolbar().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());+ let toolbar = pane.read_with(cx, |pane, _| pane.toolbar().clone());let toolbar_notify_count = Rc::new(RefCell::new(0));workspace.update_in(cx, |workspace, window, cx| {@@ -8254,7 +8254,7 @@ mod tests {.detach();});- pane.update(cx, |pane, _| {+ pane.read_with(cx, |pane, _| {assert!(!pane.can_navigate_backward());assert!(!pane.can_navigate_forward());});@@ -8266,7 +8266,7 @@ mod tests {// Toolbar must be notified to re-render the navigation buttonsassert_eq!(*toolbar_notify_count.borrow(), 1);- pane.update(cx, |pane, _| {+ pane.read_with(cx, |pane, _| {assert!(pane.can_navigate_backward());assert!(!pane.can_navigate_forward());});@@ -8279,7 +8279,7 @@ mod tests {.unwrap();assert_eq!(*toolbar_notify_count.borrow(), 2);- pane.update(cx, |pane, _| {+ pane.read_with(cx, |pane, _| {assert!(!pane.can_navigate_backward());assert!(pane.can_navigate_forward());});@@ -8305,7 +8305,7 @@ mod tests {panel});- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());pane.update_in(cx, |pane, window, cx| {let item = cx.new(TestItem::new);pane.add_item(Box::new(item), true, true, None, window, cx);@@ -8871,7 +8871,7 @@ mod tests {// Emitting a ZoomIn event shows the panel as zoomed.panel_1.update(cx, |_, cx| cx.emit(PanelEvent::ZoomIn));- workspace.update(cx, |workspace, _| {+ workspace.read_with(cx, |workspace, _| {assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));assert_eq!(workspace.zoomed_position, Some(DockPosition::Left));});@@ -8880,7 +8880,7 @@ mod tests {panel_1.update_in(cx, |panel, window, cx| {panel.set_position(DockPosition::Right, window, cx)});- workspace.update(cx, |workspace, _| {+ workspace.read_with(cx, |workspace, _| {assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));@@ -8907,7 +8907,7 @@ mod tests {// If focus is transferred to another view that's not a panel or another pane, we still show// the panel as zoomed.focus_other_view(cx);- workspace.update(cx, |workspace, _| {+ workspace.read_with(cx, |workspace, _| {assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));});@@ -8916,7 +8916,7 @@ mod tests {workspace.update_in(cx, |_workspace, window, cx| {cx.focus_self(window);});- workspace.update(cx, |workspace, _| {+ workspace.read_with(cx, |workspace, _| {assert_eq!(workspace.zoomed, None);assert_eq!(workspace.zoomed_position, None);});@@ -8924,21 +8924,21 @@ mod tests {// If focus is transferred again to another view that's not a panel or a pane, we won't// show the panel as zoomed because it wasn't zoomed before.focus_other_view(cx);- workspace.update(cx, |workspace, _| {+ workspace.read_with(cx, |workspace, _| {assert_eq!(workspace.zoomed, None);assert_eq!(workspace.zoomed_position, None);});// When the panel is activated, it is zoomed again.cx.dispatch_action(ToggleRightDock);- workspace.update(cx, |workspace, _| {+ workspace.read_with(cx, |workspace, _| {assert_eq!(workspace.zoomed, Some(panel_1.to_any().downgrade()));assert_eq!(workspace.zoomed_position, Some(DockPosition::Right));});// Emitting a ZoomOut event unzooms the panel.panel_1.update(cx, |_, cx| cx.emit(PanelEvent::ZoomOut));- workspace.update(cx, |workspace, _| {+ workspace.read_with(cx, |workspace, _| {assert_eq!(workspace.zoomed, None);assert_eq!(workspace.zoomed_position, None);});@@ -8961,7 +8961,7 @@ mod tests {let project = Project::test(fs, [], cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let dirty_regular_buffer = cx.new(|cx| {TestItem::new(cx)@@ -9109,7 +9109,7 @@ mod tests {let project = Project::test(fs, [], cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let dirty_regular_buffer = cx.new(|cx| {TestItem::new(cx)@@ -9199,7 +9199,7 @@ mod tests {let project = Project::test(fs, [], cx).await;let (workspace, cx) =cx.add_window_view(|window, cx| Workspace::test_new(project, window, cx));- let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());+ let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());let dirty_regular_buffer = cx.new(|cx| {TestItem::new(cx)diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rsindex bb45dcbd04b..fe8104e1cdb 100644--- a/crates/worktree/src/worktree.rs+++ b/crates/worktree/src/worktree.rs@@ -880,7 +880,7 @@ impl Worktree {.await.map(CreatedEntry::Included),None => {- let abs_path = this.update(cx, |worktree, _| {+ let abs_path = this.read_with(cx, |worktree, _| {worktree.absolutize(&path).with_context(|| format!("absolutizing {path:?}"))@@ -2027,7 +2027,7 @@ impl LocalWorktree {cx.spawn(async move |this, cx| {refresh.recv().await;log::trace!("refreshed entry {path:?} in {:?}", t0.elapsed());- let new_entry = this.update(cx, |this, _| {+ let new_entry = this.read_with(cx, |this, _| {this.entry_for_path(path).cloned().context("reading path after update")@@ -2274,7 +2274,7 @@ impl RemoteWorktree {.await.map(CreatedEntry::Included),None => {- let abs_path = this.update(cx, |worktree, _| {+ let abs_path = this.read_with(cx, |worktree, _| {worktree.absolutize(&new_path).with_context(|| format!("absolutizing {new_path:?}"))@@ -5082,7 +5082,7 @@ impl WorktreeModelHandle for Entity<Worktree> {let file_name = "fs-event-sentinel";let tree = self.clone();- let (fs, root_path) = self.update(cx, |tree, _| {+ let (fs, root_path) = self.read_with(cx, |tree, _| {let tree = tree.as_local().unwrap();(tree.fs.clone(), tree.abs_path().clone())});@@ -5094,7 +5094,7 @@ impl WorktreeModelHandle for Entity<Worktree> {let mut events = cx.events(&tree);while events.next().await.is_some() {- if tree.update(cx, |tree, _| tree.entry_for_path(file_name).is_some()) {+ if tree.read_with(cx, |tree, _| tree.entry_for_path(file_name).is_some()) {break;}}@@ -5103,7 +5103,7 @@ impl WorktreeModelHandle for Entity<Worktree> {.await.unwrap();while events.next().await.is_some() {- if tree.update(cx, |tree, _| tree.entry_for_path(file_name).is_none()) {+ if tree.read_with(cx, |tree, _| tree.entry_for_path(file_name).is_none()) {break;}}@@ -5128,7 +5128,7 @@ impl WorktreeModelHandle for Entity<Worktree> {let file_name = "fs-event-sentinel";let tree = self.clone();- let (fs, root_path, mut git_dir_scan_id) = self.update(cx, |tree, _| {+ let (fs, root_path, mut git_dir_scan_id) = self.read_with(cx, |tree, _| {let tree = tree.as_local().unwrap();let local_repo_entry = tree.git_repositoriesdiff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex 2a5c74bc9c5..5bd0075cad3 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -1535,10 +1535,10 @@ fn open_local_file(cx.spawn_in(window, async move |workspace, cx| {// Check if the file actually exists on disk (even if it's excluded from worktree)let file_exists = {- let full_path =- worktree.update(cx, |tree, _| tree.abs_path().join(settings_relative_path))?;+ let full_path = worktree+ .read_with(cx, |tree, _| tree.abs_path().join(settings_relative_path))?;- let fs = project.update(cx, |project, _| project.fs().clone())?;+ let fs = project.read_with(cx, |project, _| project.fs().clone())?;let file_exists = fs.metadata(&full_path).await@@ -1550,7 +1550,7 @@ fn open_local_file(if !file_exists {if let Some(dir_path) = settings_relative_path.parent() {- if worktree.update(cx, |tree, _| tree.entry_for_path(dir_path).is_none())? {+ if worktree.read_with(cx, |tree, _| tree.entry_for_path(dir_path).is_none())? {project.update(cx, |project, cx| {project.create_entry((tree_id, dir_path), true, cx)@@ -1560,7 +1560,7 @@ fn open_local_file(}}- if worktree.update(cx, |tree, _| {+ if worktree.read_with(cx, |tree, _| {tree.entry_for_path(settings_relative_path).is_none()})? {project