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
|
@ -2066,7 +2066,7 @@ async fn share_workspace(
|
|||
workspace: &Entity<Workspace>,
|
||||
cx: &mut VisualTestContext,
|
||||
) -> anyhow::Result<u64> {
|
||||
let project = workspace.update(cx, |workspace, _| workspace.project().clone());
|
||||
let project = workspace.read_with(cx, |workspace, _| workspace.project().clone());
|
||||
cx.read(ActiveCall::global)
|
||||
.update(cx, |call, cx| call.share_project(project, cx))
|
||||
.await
|
||||
|
|
|
@ -6416,7 +6416,7 @@ async fn test_join_after_restart(cx1: &mut TestAppContext, cx2: &mut TestAppCont
|
|||
async fn test_preview_tabs(cx: &mut TestAppContext) {
|
||||
let (_server, client) = TestServer::start1(cx).await;
|
||||
let (workspace, cx) = client.build_test_workspace(cx).await;
|
||||
let project = workspace.update(cx, |workspace, _| workspace.project().clone());
|
||||
let project = workspace.read_with(cx, |workspace, _| workspace.project().clone());
|
||||
|
||||
let worktree_id = project.update(cx, |project, cx| {
|
||||
project.worktrees(cx).next().unwrap().read(cx).id()
|
||||
|
@ -6435,7 +6435,7 @@ async fn test_preview_tabs(cx: &mut TestAppContext) {
|
|||
path: Path::new("3.rs").into(),
|
||||
};
|
||||
|
||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
||||
let pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||
|
||||
let get_path = |pane: &Pane, idx: usize, cx: &App| {
|
||||
pane.item_for_index(idx).unwrap().project_path(cx).unwrap()
|
||||
|
@ -6588,7 +6588,7 @@ async fn test_preview_tabs(cx: &mut TestAppContext) {
|
|||
pane.split(workspace::SplitDirection::Right, cx);
|
||||
});
|
||||
|
||||
let right_pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
||||
let right_pane = workspace.read_with(cx, |workspace, _| workspace.active_pane().clone());
|
||||
|
||||
pane.update(cx, |pane, cx| {
|
||||
assert_eq!(pane.items_len(), 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue