Sync config with ssh remotes (#17349)
Release Notes: - N/A --------- Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
4b094798e0
commit
7fb94c4c4d
13 changed files with 609 additions and 193 deletions
|
@ -11,39 +11,49 @@ use gpui::{AppContext, Context, Model, ModelContext, Task};
|
|||
use settings::Settings as _;
|
||||
use worktree::WorktreeId;
|
||||
|
||||
use crate::project_settings::{DirenvSettings, ProjectSettings};
|
||||
use crate::{
|
||||
project_settings::{DirenvSettings, ProjectSettings},
|
||||
worktree_store::{WorktreeStore, WorktreeStoreEvent},
|
||||
};
|
||||
|
||||
pub(crate) struct ProjectEnvironment {
|
||||
pub struct ProjectEnvironment {
|
||||
cli_environment: Option<HashMap<String, String>>,
|
||||
get_environment_task: Option<Shared<Task<Option<HashMap<String, String>>>>>,
|
||||
cached_shell_environments: HashMap<WorktreeId, HashMap<String, String>>,
|
||||
}
|
||||
|
||||
impl ProjectEnvironment {
|
||||
pub(crate) fn new(
|
||||
pub fn new(
|
||||
worktree_store: &Model<WorktreeStore>,
|
||||
cli_environment: Option<HashMap<String, String>>,
|
||||
cx: &mut AppContext,
|
||||
) -> Model<Self> {
|
||||
cx.new_model(|_| Self {
|
||||
cli_environment,
|
||||
get_environment_task: None,
|
||||
cached_shell_environments: Default::default(),
|
||||
cx.new_model(|cx| {
|
||||
cx.subscribe(worktree_store, |this: &mut Self, _, event, _| match event {
|
||||
WorktreeStoreEvent::WorktreeRemoved(_, id) => {
|
||||
this.remove_worktree_environment(*id);
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.detach();
|
||||
|
||||
Self {
|
||||
cli_environment,
|
||||
get_environment_task: None,
|
||||
cached_shell_environments: Default::default(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub(crate) fn test(
|
||||
pub(crate) fn set_cached(
|
||||
&mut self,
|
||||
shell_environments: &[(WorktreeId, HashMap<String, String>)],
|
||||
cx: &mut AppContext,
|
||||
) -> Model<Self> {
|
||||
cx.new_model(|_| Self {
|
||||
cli_environment: None,
|
||||
get_environment_task: None,
|
||||
cached_shell_environments: shell_environments
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<HashMap<_, _>>(),
|
||||
})
|
||||
) {
|
||||
self.cached_shell_environments = shell_environments
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<HashMap<_, _>>();
|
||||
}
|
||||
|
||||
pub(crate) fn remove_worktree_environment(&mut self, worktree_id: WorktreeId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue