Remove AppState from workspace actions
This allows those actions to be bound to keystrokes in the keymap. Also, remove the WorkspaceParams struct, simplify how Workspaces are constructed.
This commit is contained in:
parent
7445197f4d
commit
ef0b584532
21 changed files with 335 additions and 486 deletions
|
@ -1630,7 +1630,7 @@ mod tests {
|
|||
use gpui::{
|
||||
executor::{self, Deterministic},
|
||||
geometry::vector::vec2f,
|
||||
ModelHandle, TestAppContext, ViewHandle,
|
||||
ModelHandle, Task, TestAppContext, ViewHandle,
|
||||
};
|
||||
use language::{
|
||||
range_to_lsp, tree_sitter_rust, Diagnostic, DiagnosticEntry, FakeLspAdapter, Language,
|
||||
|
@ -1662,7 +1662,7 @@ mod tests {
|
|||
time::Duration,
|
||||
};
|
||||
use theme::ThemeRegistry;
|
||||
use workspace::{Item, SplitDirection, ToggleFollow, Workspace, WorkspaceParams};
|
||||
use workspace::{Item, SplitDirection, ToggleFollow, Workspace};
|
||||
|
||||
#[cfg(test)]
|
||||
#[ctor::ctor]
|
||||
|
@ -4322,13 +4322,7 @@ mod tests {
|
|||
|
||||
// Join the project as client B.
|
||||
let project_b = client_b.build_remote_project(&project_a, cx_a, cx_b).await;
|
||||
let mut params = cx_b.update(WorkspaceParams::test);
|
||||
params.languages = lang_registry.clone();
|
||||
params.project = project_b.clone();
|
||||
params.client = client_b.client.clone();
|
||||
params.user_store = client_b.user_store.clone();
|
||||
|
||||
let (_window_b, workspace_b) = cx_b.add_window(|cx| Workspace::new(¶ms, cx));
|
||||
let (_window_b, workspace_b) = cx_b.add_window(|cx| Workspace::new(project_b.clone(), cx));
|
||||
let editor_b = workspace_b
|
||||
.update(cx_b, |workspace, cx| {
|
||||
workspace.open_path((worktree_id, "main.rs"), true, cx)
|
||||
|
@ -4563,13 +4557,7 @@ mod tests {
|
|||
|
||||
// Join the worktree as client B.
|
||||
let project_b = client_b.build_remote_project(&project_a, cx_a, cx_b).await;
|
||||
let mut params = cx_b.update(WorkspaceParams::test);
|
||||
params.languages = lang_registry.clone();
|
||||
params.project = project_b.clone();
|
||||
params.client = client_b.client.clone();
|
||||
params.user_store = client_b.user_store.clone();
|
||||
|
||||
let (_window_b, workspace_b) = cx_b.add_window(|cx| Workspace::new(¶ms, cx));
|
||||
let (_window_b, workspace_b) = cx_b.add_window(|cx| Workspace::new(project_b.clone(), cx));
|
||||
let editor_b = workspace_b
|
||||
.update(cx_b, |workspace, cx| {
|
||||
workspace.open_path((worktree_id, "one.rs"), true, cx)
|
||||
|
@ -6602,13 +6590,21 @@ mod tests {
|
|||
})
|
||||
});
|
||||
|
||||
Channel::init(&client);
|
||||
Project::init(&client);
|
||||
cx.update(|cx| {
|
||||
workspace::init(&client, cx);
|
||||
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http, cx));
|
||||
let app_state = Arc::new(workspace::AppState {
|
||||
client: client.clone(),
|
||||
user_store: user_store.clone(),
|
||||
languages: Arc::new(LanguageRegistry::new(Task::ready(()))),
|
||||
themes: ThemeRegistry::new((), cx.font_cache()),
|
||||
fs: FakeFs::new(cx.background()),
|
||||
build_window_options: || Default::default(),
|
||||
build_workspace: |_, _, _| unimplemented!(),
|
||||
});
|
||||
|
||||
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http, cx));
|
||||
Channel::init(&client);
|
||||
Project::init(&client);
|
||||
cx.update(|cx| workspace::init(app_state.clone(), cx));
|
||||
|
||||
client
|
||||
.authenticate_and_connect(false, &cx.to_async())
|
||||
.await
|
||||
|
@ -6846,23 +6842,7 @@ mod tests {
|
|||
cx: &mut TestAppContext,
|
||||
) -> ViewHandle<Workspace> {
|
||||
let (window_id, _) = cx.add_window(|_| EmptyView);
|
||||
cx.add_view(window_id, |cx| {
|
||||
let fs = project.read(cx).fs().clone();
|
||||
Workspace::new(
|
||||
&WorkspaceParams {
|
||||
fs,
|
||||
project: project.clone(),
|
||||
user_store: self.user_store.clone(),
|
||||
languages: self.language_registry.clone(),
|
||||
themes: ThemeRegistry::new((), cx.font_cache().clone()),
|
||||
channel_list: cx.add_model(|cx| {
|
||||
ChannelList::new(self.user_store.clone(), self.client.clone(), cx)
|
||||
}),
|
||||
client: self.client.clone(),
|
||||
},
|
||||
cx,
|
||||
)
|
||||
})
|
||||
cx.add_view(window_id, |cx| Workspace::new(project.clone(), cx))
|
||||
}
|
||||
|
||||
async fn simulate_host(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue