Use read-only access methods for read-only entity operations (#31479)
Another follow-up to #31254 Release Notes: - N/A
This commit is contained in:
@@ -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
|
||||
.matches
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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")));
|
||||
};
|
||||
|
||||
@@ -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| {
|
||||
|
||||
@@ -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| {
|
||||
|
||||
@@ -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_id
|
||||
|
||||
Reference in New Issue
Block a user