Fix lsp_restart across multiple different document scopes (language servers weren't restarted, if not of the same scope id), and fix some smaller rebase issues

pull/2507/head
Philipp Mildenberger 2 years ago
parent 2a21b939c4
commit 3e4bac1d96

@ -691,7 +691,6 @@ impl Registry {
.language_servers .language_servers
.iter() .iter()
.filter_map(|LanguageServerFeatures { name, .. }| { .filter_map(|LanguageServerFeatures { name, .. }| {
// #[allow(clippy::map_entry)]
if self.inner.contains_key(name) { if self.inner.contains_key(name) {
let client = match self.start_client( let client = match self.start_client(
name.clone(), name.clone(),
@ -708,7 +707,7 @@ impl Registry {
.insert(name.clone(), vec![client.clone()]) .insert(name.clone(), vec![client.clone()])
.unwrap(); .unwrap();
// TODO what if there are different language servers for different workspaces, // TODO what if there are multiple instances for different workspaces?
// I think the language servers will be stopped without being restarted, which is not intended // I think the language servers will be stopped without being restarted, which is not intended
for old_client in old_clients { for old_client in old_clients {
tokio::spawn(async move { tokio::spawn(async move {
@ -745,15 +744,12 @@ impl Registry {
.language_servers .language_servers
.iter() .iter()
.map(|LanguageServerFeatures { name, .. }| { .map(|LanguageServerFeatures { name, .. }| {
if let Some(clients) = self.inner.get_mut(name) { if let Some(clients) = self.inner.get(name) {
// clients.find( if let Some((_, client)) = clients.iter().enumerate().find(|(i, client)| {
if let Some((_, client)) = clients.iter_mut().enumerate().find(|(i, client)| {
client.try_add_doc(&language_config.roots, root_dirs, doc_path, *i == 0) client.try_add_doc(&language_config.roots, root_dirs, doc_path, *i == 0)
}) { }) {
return Ok((name.to_owned(), client.clone())); return Ok((name.to_owned(), client.clone()));
} }
// return Ok((name.clone(), clients.clone()));
} }
let client = self.start_client( let client = self.start_client(
name.clone(), name.clone(),

@ -1404,7 +1404,6 @@ fn lsp_restart(
.language_config() .language_config()
.context("LSP not defined for the current document")?; .context("LSP not defined for the current document")?;
let scope = config.scope.clone();
cx.editor.language_servers.restart( cx.editor.language_servers.restart(
config, config,
doc.path(), doc.path(),
@ -1417,7 +1416,16 @@ fn lsp_restart(
.editor .editor
.documents() .documents()
.filter_map(|doc| match doc.language_config() { .filter_map(|doc| match doc.language_config() {
Some(config) if config.scope.eq(&scope) => Some(doc.id()), Some(config)
if config.language_servers.iter().any(|ls| {
config
.language_servers
.iter()
.any(|restarted_ls| restarted_ls.name == ls.name)
}) =>
{
Some(doc.id())
}
_ => None, _ => None,
}) })
.collect(); .collect();

Loading…
Cancel
Save