Make NodeRuntime non-static for prettier runner

This commit is contained in:
Kirill Bulatov 2023-09-06 18:49:56 +03:00
parent a8387b8b19
commit ce6b31d938
6 changed files with 39 additions and 20 deletions

View file

@ -30,6 +30,7 @@ gpui = { path = "../gpui" }
install_cli = { path = "../install_cli" }
language = { path = "../language" }
menu = { path = "../menu" }
node_runtime = { path = "../node_runtime" }
project = { path = "../project" }
settings = { path = "../settings" }
terminal = { path = "../terminal" }

View file

@ -42,6 +42,7 @@ use gpui::{
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ProjectItem};
use itertools::Itertools;
use language::{LanguageRegistry, Rope};
use node_runtime::NodeRuntime;
use std::{
any::TypeId,
borrow::Cow,
@ -456,6 +457,7 @@ pub struct AppState {
pub initialize_workspace:
fn(WeakViewHandle<Workspace>, bool, Arc<AppState>, AsyncAppContext) -> Task<Result<()>>,
pub background_actions: BackgroundActions,
pub node_runtime: Arc<dyn NodeRuntime>,
}
pub struct WorkspaceStore {
@ -474,6 +476,7 @@ struct Follower {
impl AppState {
#[cfg(any(test, feature = "test-support"))]
pub fn test(cx: &mut AppContext) -> Arc<Self> {
use node_runtime::FakeNodeRuntime;
use settings::SettingsStore;
if !cx.has_global::<SettingsStore>() {
@ -498,6 +501,7 @@ impl AppState {
user_store,
// channel_store,
workspace_store,
node_runtime: FakeNodeRuntime::new(),
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
build_window_options: |_, _, _| Default::default(),
background_actions: || &[],
@ -816,6 +820,7 @@ impl Workspace {
)> {
let project_handle = Project::local(
app_state.client.clone(),
app_state.node_runtime.clone(),
app_state.user_store.clone(),
app_state.languages.clone(),
app_state.fs.clone(),
@ -3517,6 +3522,8 @@ impl Workspace {
#[cfg(any(test, feature = "test-support"))]
pub fn test_new(project: ModelHandle<Project>, cx: &mut ViewContext<Self>) -> Self {
use node_runtime::FakeNodeRuntime;
let client = project.read(cx).client();
let user_store = project.read(cx).user_store();
@ -3530,6 +3537,7 @@ impl Workspace {
build_window_options: |_, _, _| Default::default(),
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
background_actions: || &[],
node_runtime: FakeNodeRuntime::new(),
});
Self::new(0, project, app_state, cx)
}