Use read-only access methods for read-only entity operations (#31254)
This PR replaces some `update()` calls with either `read()` or `read_with()` when the `update()` call performed read-only operations on the entity. Many more likely exist, will follow-up with more PRs. Release Notes: - N/A
This commit is contained in:
parent
508ccde363
commit
f435304209
11 changed files with 20 additions and 20 deletions
|
@ -1213,7 +1213,7 @@ mod tests {
|
|||
assert_eq!(worktrees.len(), 1);
|
||||
worktrees.pop().unwrap()
|
||||
});
|
||||
let worktree_id = worktree.update(cx, |worktree, _| worktree.id());
|
||||
let worktree_id = worktree.read_with(cx, |worktree, _| worktree.id());
|
||||
|
||||
let mut cx = VisualTestContext::from_window(*window.deref(), cx);
|
||||
|
||||
|
|
|
@ -326,9 +326,7 @@ impl<T: 'static> PromptEditor<T> {
|
|||
EditorEvent::Edited { .. } => {
|
||||
if let Some(workspace) = window.root::<Workspace>().flatten() {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
let is_via_ssh = workspace
|
||||
.project()
|
||||
.update(cx, |project, _| project.is_via_ssh());
|
||||
let is_via_ssh = workspace.project().read(cx).is_via_ssh();
|
||||
|
||||
workspace
|
||||
.client()
|
||||
|
|
|
@ -2851,7 +2851,8 @@ mod tests {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
let context = context_store.update(cx, |store, _| store.context().next().cloned().unwrap());
|
||||
let context =
|
||||
context_store.read_with(cx, |store, _| store.context().next().cloned().unwrap());
|
||||
let loaded_context = cx
|
||||
.update(|cx| load_context(vec![context], &project, &None, cx))
|
||||
.await;
|
||||
|
@ -3162,7 +3163,8 @@ fn main() {{
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
let context = context_store.update(cx, |store, _| store.context().next().cloned().unwrap());
|
||||
let context =
|
||||
context_store.read_with(cx, |store, _| store.context().next().cloned().unwrap());
|
||||
let loaded_context = cx
|
||||
.update(|cx| load_context(vec![context], &project, &None, cx))
|
||||
.await;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue