
This is the core change: https://github.com/zed-industries/zed/pull/26758/files#diff-044302c0d57147af17e68a0009fee3e8dcdfb4f32c27a915e70cfa80e987f765R1052 TODO: - [x] Use AsyncFn instead of Fn() -> Future in GPUI spawn methods - [x] Implement it in the whole app - [x] Implement it in the debugger - [x] Glance at the RPC crate, and see if those box future methods can be switched over. Answer: It can't directly, as you can't make an AsyncFn* into a trait object. There's ways around that, but they're all more complex than just keeping the code as is. - [ ] Fix platform specific code Release Notes: - N/A
83 lines
2.3 KiB
Rust
83 lines
2.3 KiB
Rust
use gpui::{Entity, TestAppContext, WindowHandle};
|
|
use project::Project;
|
|
use settings::SettingsStore;
|
|
use terminal_view::terminal_panel::TerminalPanel;
|
|
use workspace::Workspace;
|
|
|
|
use crate::{debugger_panel::DebugPanel, session::DebugSession};
|
|
|
|
mod attach_modal;
|
|
mod console;
|
|
mod debugger_panel;
|
|
mod module_list;
|
|
mod stack_frame_list;
|
|
mod variable_list;
|
|
|
|
pub fn init_test(cx: &mut gpui::TestAppContext) {
|
|
if std::env::var("RUST_LOG").is_ok() {
|
|
env_logger::try_init().ok();
|
|
}
|
|
|
|
cx.update(|cx| {
|
|
let settings = SettingsStore::test(cx);
|
|
cx.set_global(settings);
|
|
terminal_view::init(cx);
|
|
theme::init(theme::LoadThemes::JustBase, cx);
|
|
command_palette_hooks::init(cx);
|
|
language::init(cx);
|
|
workspace::init_settings(cx);
|
|
Project::init_settings(cx);
|
|
editor::init(cx);
|
|
crate::init(cx);
|
|
});
|
|
}
|
|
|
|
pub async fn init_test_workspace(
|
|
project: &Entity<Project>,
|
|
cx: &mut TestAppContext,
|
|
) -> WindowHandle<Workspace> {
|
|
let workspace_handle =
|
|
cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx));
|
|
|
|
let debugger_panel = workspace_handle
|
|
.update(cx, |_, window, cx| {
|
|
cx.spawn_in(window, async move |this, cx| {
|
|
DebugPanel::load(this, cx.clone()).await
|
|
})
|
|
})
|
|
.unwrap()
|
|
.await
|
|
.expect("Failed to load debug panel");
|
|
|
|
let terminal_panel = workspace_handle
|
|
.update(cx, |_, window, cx| {
|
|
cx.spawn_in(window, async |this, cx| {
|
|
TerminalPanel::load(this, cx.clone()).await
|
|
})
|
|
})
|
|
.unwrap()
|
|
.await
|
|
.expect("Failed to load terminal panel");
|
|
|
|
workspace_handle
|
|
.update(cx, |workspace, window, cx| {
|
|
workspace.add_panel(debugger_panel, window, cx);
|
|
workspace.add_panel(terminal_panel, window, cx);
|
|
})
|
|
.unwrap();
|
|
workspace_handle
|
|
}
|
|
|
|
pub fn active_debug_session_panel(
|
|
workspace: WindowHandle<Workspace>,
|
|
cx: &mut TestAppContext,
|
|
) -> Entity<DebugSession> {
|
|
workspace
|
|
.update(cx, |workspace, _window, cx| {
|
|
let debug_panel = workspace.panel::<DebugPanel>(cx).unwrap();
|
|
debug_panel
|
|
.update(cx, |this, cx| this.active_session(cx))
|
|
.unwrap()
|
|
})
|
|
.unwrap()
|
|
}
|