Extract a BufferStore object from Project (#14037)
This is a ~small~ pure refactor that's a step toward SSH remoting. I've extracted the Project's buffer state management into a smaller, separate struct called `BufferStore`, currently in the same crate. I did this as a separate PR to reduce conflicts between main and `remoting-over-ssh`. The idea is to make use of this struct (and other smaller structs that make up `Project`) in a dedicated, simpler `HeadlessProject` type that we will use in the SSH server to model the remote end of a project. With this approach, as we develop the headless project, we can avoid adding more conditional logic to `Project` itself (which is already very complex), and actually make `Project` a bit smaller by extracting out helper objects. Release Notes: - N/A
This commit is contained in:
parent
21c5ce2bbd
commit
489077befc
15 changed files with 1394 additions and 1115 deletions
|
@ -3327,7 +3327,7 @@ async fn test_local_settings(
|
|||
let store = cx.global::<SettingsStore>();
|
||||
assert_eq!(
|
||||
store
|
||||
.local_settings(worktree_b.read(cx).id().to_usize())
|
||||
.local_settings(worktree_b.entity_id().as_u64() as _)
|
||||
.collect::<Vec<_>>(),
|
||||
&[
|
||||
(Path::new("").into(), r#"{"tab_size":2}"#.to_string()),
|
||||
|
@ -3346,7 +3346,7 @@ async fn test_local_settings(
|
|||
let store = cx.global::<SettingsStore>();
|
||||
assert_eq!(
|
||||
store
|
||||
.local_settings(worktree_b.read(cx).id().to_usize())
|
||||
.local_settings(worktree_b.entity_id().as_u64() as _)
|
||||
.collect::<Vec<_>>(),
|
||||
&[
|
||||
(Path::new("").into(), r#"{}"#.to_string()),
|
||||
|
@ -3375,7 +3375,7 @@ async fn test_local_settings(
|
|||
let store = cx.global::<SettingsStore>();
|
||||
assert_eq!(
|
||||
store
|
||||
.local_settings(worktree_b.read(cx).id().to_usize())
|
||||
.local_settings(worktree_b.entity_id().as_u64() as _)
|
||||
.collect::<Vec<_>>(),
|
||||
&[
|
||||
(Path::new("a").into(), r#"{"tab_size":8}"#.to_string()),
|
||||
|
@ -3407,7 +3407,7 @@ async fn test_local_settings(
|
|||
let store = cx.global::<SettingsStore>();
|
||||
assert_eq!(
|
||||
store
|
||||
.local_settings(worktree_b.read(cx).id().to_usize())
|
||||
.local_settings(worktree_b.entity_id().as_u64() as _)
|
||||
.collect::<Vec<_>>(),
|
||||
&[(Path::new("a").into(), r#"{"hard_tabs":true}"#.to_string()),]
|
||||
)
|
||||
|
|
|
@ -1237,7 +1237,7 @@ impl RandomizedTest for ProjectCollaborationTest {
|
|||
}
|
||||
}
|
||||
|
||||
for buffer in guest_project.opened_buffers() {
|
||||
for buffer in guest_project.opened_buffers(cx) {
|
||||
let buffer = buffer.read(cx);
|
||||
assert_eq!(
|
||||
buffer.deferred_ops_len(),
|
||||
|
@ -1287,8 +1287,8 @@ impl RandomizedTest for ProjectCollaborationTest {
|
|||
for guest_buffer in guest_buffers {
|
||||
let buffer_id =
|
||||
guest_buffer.read_with(client_cx, |buffer, _| buffer.remote_id());
|
||||
let host_buffer = host_project.read_with(host_cx, |project, _| {
|
||||
project.buffer_for_id(buffer_id).unwrap_or_else(|| {
|
||||
let host_buffer = host_project.read_with(host_cx, |project, cx| {
|
||||
project.buffer_for_id(buffer_id, cx).unwrap_or_else(|| {
|
||||
panic!(
|
||||
"host does not have buffer for guest:{}, peer:{:?}, id:{}",
|
||||
client.username,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue