mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
fix lsp restart (#10614)
This commit is contained in:
parent
bc03b6b5fe
commit
a1d7997fe3
@ -736,35 +736,30 @@ pub fn restart(
|
|||||||
.language_servers
|
.language_servers
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|LanguageServerFeatures { name, .. }| {
|
.filter_map(|LanguageServerFeatures { name, .. }| {
|
||||||
if self.inner_by_name.contains_key(name) {
|
if let Some(old_clients) = self.inner_by_name.remove(name) {
|
||||||
let client = match self.start_client(
|
|
||||||
name.clone(),
|
|
||||||
language_config,
|
|
||||||
doc_path,
|
|
||||||
root_dirs,
|
|
||||||
enable_snippets,
|
|
||||||
) {
|
|
||||||
Ok(client) => client,
|
|
||||||
Err(StartupError::NoRequiredRootFound) => return None,
|
|
||||||
Err(StartupError::Error(err)) => return Some(Err(err)),
|
|
||||||
};
|
|
||||||
let old_clients = self
|
|
||||||
.inner_by_name
|
|
||||||
.insert(name.clone(), vec![client.clone()])
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
for old_client in old_clients {
|
for old_client in old_clients {
|
||||||
self.file_event_handler.remove_client(old_client.id());
|
self.file_event_handler.remove_client(old_client.id());
|
||||||
self.inner.remove(client.id());
|
self.inner.remove(old_client.id());
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let _ = old_client.force_shutdown().await;
|
let _ = old_client.force_shutdown().await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Ok(client))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
let client = match self.start_client(
|
||||||
|
name.clone(),
|
||||||
|
language_config,
|
||||||
|
doc_path,
|
||||||
|
root_dirs,
|
||||||
|
enable_snippets,
|
||||||
|
) {
|
||||||
|
Ok(client) => client,
|
||||||
|
Err(StartupError::NoRequiredRootFound) => return None,
|
||||||
|
Err(StartupError::Error(err)) => return Some(Err(err)),
|
||||||
|
};
|
||||||
|
self.inner_by_name
|
||||||
|
.insert(name.to_owned(), vec![client.clone()]);
|
||||||
|
|
||||||
|
Some(Ok(client))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user