Rename open_buffer_for_path to open_buffer

This commit is contained in:
Antonio Scandurra 2022-03-17 11:42:13 +01:00
parent e6755f4115
commit 6446660c88
5 changed files with 64 additions and 143 deletions

View file

@ -1137,9 +1137,7 @@ mod tests {
// Open the same file as client B and client A.
let buffer_b = project_b
.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "b.txt"), cx)
})
.update(cx_b, |p, cx| p.open_buffer((worktree_id, "b.txt"), cx))
.await
.unwrap();
let buffer_b = cx_b.add_model(|cx| MultiBuffer::singleton(buffer_b, cx));
@ -1150,9 +1148,7 @@ mod tests {
assert!(project.has_open_buffer((worktree_id, "b.txt"), cx))
});
let buffer_a = project_a
.update(cx_a, |p, cx| {
p.open_buffer_for_path((worktree_id, "b.txt"), cx)
})
.update(cx_a, |p, cx| p.open_buffer((worktree_id, "b.txt"), cx))
.await
.unwrap();
@ -1242,9 +1238,7 @@ mod tests {
.await
.unwrap();
project_b
.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.txt"), cx)
})
.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
.await
.unwrap();
@ -1279,9 +1273,7 @@ mod tests {
.await
.unwrap();
project_b2
.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.txt"), cx)
})
.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
.await
.unwrap();
}
@ -1360,15 +1352,11 @@ mod tests {
// Open and edit a buffer as both guests B and C.
let buffer_b = project_b
.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "file1"), cx)
})
.update(cx_b, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
.await
.unwrap();
let buffer_c = project_c
.update(cx_c, |p, cx| {
p.open_buffer_for_path((worktree_id, "file1"), cx)
})
.update(cx_c, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
.await
.unwrap();
buffer_b.update(cx_b, |buf, cx| buf.edit([0..0], "i-am-b, ", cx));
@ -1376,9 +1364,7 @@ mod tests {
// Open and edit that buffer as the host.
let buffer_a = project_a
.update(cx_a, |p, cx| {
p.open_buffer_for_path((worktree_id, "file1"), cx)
})
.update(cx_a, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
.await
.unwrap();
@ -1528,9 +1514,7 @@ mod tests {
// Open a buffer as client B
let buffer_b = project_b
.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.txt"), cx)
})
.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
.await
.unwrap();
@ -1613,9 +1597,7 @@ mod tests {
// Open a buffer as client B
let buffer_b = project_b
.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.txt"), cx)
})
.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
.await
.unwrap();
buffer_b.read_with(cx_b, |buf, _| {
@ -1695,16 +1677,14 @@ mod tests {
// Open a buffer as client A
let buffer_a = project_a
.update(cx_a, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.txt"), cx)
})
.update(cx_a, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx))
.await
.unwrap();
// Start opening the same buffer as client B
let buffer_b = cx_b.background().spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.txt"), cx)
}));
let buffer_b = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx)));
// Edit the buffer as client A while client B is still opening it.
cx_b.background().simulate_random_delay().await;
@ -1780,9 +1760,9 @@ mod tests {
.await;
// Begin opening a buffer as client B, but leave the project before the open completes.
let buffer_b = cx_b.background().spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.txt"), cx)
}));
let buffer_b = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.txt"), cx)));
cx_b.update(|_| drop(project_b));
drop(buffer_b);
@ -1952,7 +1932,7 @@ mod tests {
let _ = cx_a
.background()
.spawn(project_a.update(cx_a, |project, cx| {
project.open_buffer_for_path(
project.open_buffer(
ProjectPath {
worktree_id,
path: Path::new("other.rs").into(),
@ -2073,9 +2053,7 @@ mod tests {
// Open the file with the errors on client B. They should be present.
let buffer_b = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.rs"), cx)
}))
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
.await
.unwrap();
@ -2193,9 +2171,7 @@ mod tests {
// Open a file in an editor as the guest.
let buffer_b = project_b
.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "main.rs"), cx)
})
.update(cx_b, |p, cx| p.open_buffer((worktree_id, "main.rs"), cx))
.await
.unwrap();
let (window_b, _) = cx_b.add_window(|_| EmptyView);
@ -2269,9 +2245,7 @@ mod tests {
// Open the buffer on the host.
let buffer_a = project_a
.update(cx_a, |p, cx| {
p.open_buffer_for_path((worktree_id, "main.rs"), cx)
})
.update(cx_a, |p, cx| p.open_buffer((worktree_id, "main.rs"), cx))
.await
.unwrap();
buffer_a
@ -2395,9 +2369,7 @@ mod tests {
let buffer_b = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.rs"), cx)
}))
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
.await
.unwrap();
@ -2505,9 +2477,7 @@ mod tests {
// Open the file on client B.
let buffer_b = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.rs"), cx)
}))
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
.await
.unwrap();
@ -2646,9 +2616,7 @@ mod tests {
// Open the file on client B.
let buffer_b = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "one.rs"), cx)
}))
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "one.rs"), cx)))
.await
.unwrap();
@ -2877,9 +2845,7 @@ mod tests {
// Open the file on client B.
let buffer_b = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "main.rs"), cx)
}))
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "main.rs"), cx)))
.await
.unwrap();
@ -3026,9 +2992,7 @@ mod tests {
// Cause the language server to start.
let _buffer = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "one.rs"), cx)
}))
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "one.rs"), cx)))
.await
.unwrap();
@ -3159,9 +3123,7 @@ mod tests {
let buffer_b1 = cx_b
.background()
.spawn(project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "a.rs"), cx)
}))
.spawn(project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "a.rs"), cx)))
.await
.unwrap();
@ -3177,13 +3139,9 @@ mod tests {
let buffer_b2;
if rng.gen() {
definitions = project_b.update(cx_b, |p, cx| p.definition(&buffer_b1, 23, cx));
buffer_b2 = project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "b.rs"), cx)
});
buffer_b2 = project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "b.rs"), cx));
} else {
buffer_b2 = project_b.update(cx_b, |p, cx| {
p.open_buffer_for_path((worktree_id, "b.rs"), cx)
});
buffer_b2 = project_b.update(cx_b, |p, cx| p.open_buffer((worktree_id, "b.rs"), cx));
definitions = project_b.update(cx_b, |p, cx| p.definition(&buffer_b1, 23, cx));
}
@ -4800,7 +4758,7 @@ mod tests {
);
let buffer = project
.update(&mut cx, |project, cx| {
project.open_buffer_for_path(project_path, cx)
project.open_buffer(project_path, cx)
})
.await
.unwrap();
@ -4917,7 +4875,7 @@ mod tests {
);
let buffer = project
.update(&mut cx, |project, cx| {
project.open_buffer_for_path(project_path.clone(), cx)
project.open_buffer(project_path.clone(), cx)
})
.await
.unwrap();