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
|
@ -5,7 +5,7 @@ use crate::{
|
|||
lsp_ext_command,
|
||||
project_settings::ProjectSettings,
|
||||
relativize_path, resolve_path,
|
||||
worktree_store::WorktreeStore,
|
||||
worktree_store::{WorktreeStore, WorktreeStoreEvent},
|
||||
yarn::YarnPathStore,
|
||||
CodeAction, Completion, CoreCompletion, Hover, InlayHint, Item as _, ProjectPath,
|
||||
ProjectTransaction, ResolveState, Symbol,
|
||||
|
@ -89,7 +89,7 @@ pub struct LspStore {
|
|||
downstream_client: Option<AnyProtoClient>,
|
||||
upstream_client: Option<AnyProtoClient>,
|
||||
project_id: u64,
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
http_client: Option<Arc<dyn HttpClient>>,
|
||||
fs: Arc<dyn Fs>,
|
||||
nonce: u128,
|
||||
buffer_store: Model<BufferStore>,
|
||||
|
@ -210,12 +210,12 @@ impl LspStore {
|
|||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn new(
|
||||
pub fn new(
|
||||
buffer_store: Model<BufferStore>,
|
||||
worktree_store: Model<WorktreeStore>,
|
||||
environment: Option<Model<ProjectEnvironment>>,
|
||||
languages: Arc<LanguageRegistry>,
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
http_client: Option<Arc<dyn HttpClient>>,
|
||||
fs: Arc<dyn Fs>,
|
||||
downstream_client: Option<AnyProtoClient>,
|
||||
upstream_client: Option<AnyProtoClient>,
|
||||
|
@ -225,6 +225,8 @@ impl LspStore {
|
|||
let yarn = YarnPathStore::new(fs.clone(), cx);
|
||||
cx.subscribe(&buffer_store, Self::on_buffer_store_event)
|
||||
.detach();
|
||||
cx.subscribe(&worktree_store, Self::on_worktree_store_event)
|
||||
.detach();
|
||||
|
||||
Self {
|
||||
downstream_client,
|
||||
|
@ -278,6 +280,31 @@ impl LspStore {
|
|||
}
|
||||
}
|
||||
|
||||
fn on_worktree_store_event(
|
||||
&mut self,
|
||||
_: Model<WorktreeStore>,
|
||||
event: &WorktreeStoreEvent,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
match event {
|
||||
WorktreeStoreEvent::WorktreeAdded(worktree) => {
|
||||
if !worktree.read(cx).is_local() {
|
||||
return;
|
||||
}
|
||||
cx.subscribe(worktree, |this, worktree, event, cx| match event {
|
||||
worktree::Event::UpdatedEntries(changes) => {
|
||||
this.update_local_worktree_language_servers(&worktree, changes, cx);
|
||||
}
|
||||
worktree::Event::UpdatedGitRepositories(_)
|
||||
| worktree::Event::DeletedEntry(_) => {}
|
||||
})
|
||||
.detach()
|
||||
}
|
||||
WorktreeStoreEvent::WorktreeRemoved(_, id) => self.remove_worktree(*id, cx),
|
||||
WorktreeStoreEvent::WorktreeOrderChanged => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_buffer_event(
|
||||
&mut self,
|
||||
buffer: Model<Buffer>,
|
||||
|
@ -463,11 +490,6 @@ impl LspStore {
|
|||
self.buffer_store.clone()
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub(crate) fn set_environment(&mut self, environment: Model<ProjectEnvironment>) {
|
||||
self.environment = Some(environment);
|
||||
}
|
||||
|
||||
pub fn set_active_entry(&mut self, active_entry: Option<ProjectEntryId>) {
|
||||
self.active_entry = active_entry;
|
||||
}
|
||||
|
@ -6105,11 +6127,15 @@ impl ProjectLspAdapterDelegate {
|
|||
Task::ready(None).shared()
|
||||
};
|
||||
|
||||
let Some(http_client) = lsp_store.http_client.clone() else {
|
||||
panic!("ProjectLspAdapterDelegate cannot be constructedd on an ssh-remote yet")
|
||||
};
|
||||
|
||||
Arc::new(Self {
|
||||
lsp_store: cx.weak_model(),
|
||||
worktree: worktree.read(cx).snapshot(),
|
||||
fs: lsp_store.fs.clone(),
|
||||
http_client: lsp_store.http_client.clone(),
|
||||
http_client,
|
||||
language_registry: lsp_store.languages.clone(),
|
||||
load_shell_env_task,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue