mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
collapsible_if
This commit is contained in:
parent
3409645c3f
commit
b5eca5f2fc
7 changed files with 47 additions and 51 deletions
|
@ -310,22 +310,20 @@ fn completion_item(
|
|||
|
||||
set_score(&mut lsp_item, max_relevance, item.relevance);
|
||||
|
||||
if config.completion().enable_imports_on_the_fly {
|
||||
if !item.import_to_add.is_empty() {
|
||||
let imports: Vec<_> = item
|
||||
.import_to_add
|
||||
.into_iter()
|
||||
.filter_map(|(import_path, import_name)| {
|
||||
Some(lsp_ext::CompletionImport {
|
||||
full_import_path: import_path,
|
||||
imported_name: import_name,
|
||||
})
|
||||
if config.completion().enable_imports_on_the_fly && !item.import_to_add.is_empty() {
|
||||
let imports: Vec<_> = item
|
||||
.import_to_add
|
||||
.into_iter()
|
||||
.filter_map(|(import_path, import_name)| {
|
||||
Some(lsp_ext::CompletionImport {
|
||||
full_import_path: import_path,
|
||||
imported_name: import_name,
|
||||
})
|
||||
.collect();
|
||||
if !imports.is_empty() {
|
||||
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
|
||||
lsp_item.data = Some(to_value(data).unwrap());
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if !imports.is_empty() {
|
||||
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
|
||||
lsp_item.data = Some(to_value(data).unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -579,10 +579,10 @@ impl GlobalState {
|
|||
let path = VfsPath::from(path);
|
||||
// if the file is in mem docs, it's managed by the client via notifications
|
||||
// so only set it if its not in there
|
||||
if !self.mem_docs.contains(&path) {
|
||||
if is_changed || vfs.file_id(&path).is_none() {
|
||||
vfs.set_file_contents(path, contents);
|
||||
}
|
||||
if !self.mem_docs.contains(&path)
|
||||
&& (is_changed || vfs.file_id(&path).is_none())
|
||||
{
|
||||
vfs.set_file_contents(path, contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -454,27 +454,27 @@ impl GlobalState {
|
|||
let files_config = self.config.files();
|
||||
let project_folders = ProjectFolders::new(&self.workspaces, &files_config.exclude);
|
||||
|
||||
if self.proc_macro_clients.is_empty() || !same_workspaces {
|
||||
if self.config.expand_proc_macros() {
|
||||
tracing::info!("Spawning proc-macro servers");
|
||||
if (self.proc_macro_clients.is_empty() || !same_workspaces)
|
||||
&& self.config.expand_proc_macros()
|
||||
{
|
||||
tracing::info!("Spawning proc-macro servers");
|
||||
|
||||
self.proc_macro_clients = Arc::from_iter(self.workspaces.iter().map(|ws| {
|
||||
let path = match self.config.proc_macro_srv() {
|
||||
Some(path) => path,
|
||||
None => ws.find_sysroot_proc_macro_srv()?,
|
||||
};
|
||||
self.proc_macro_clients = Arc::from_iter(self.workspaces.iter().map(|ws| {
|
||||
let path = match self.config.proc_macro_srv() {
|
||||
Some(path) => path,
|
||||
None => ws.find_sysroot_proc_macro_srv()?,
|
||||
};
|
||||
|
||||
tracing::info!("Using proc-macro server at {path}");
|
||||
ProcMacroServer::spawn(path.clone()).map_err(|err| {
|
||||
tracing::error!(
|
||||
"Failed to run proc-macro server from path {path}, error: {err:?}",
|
||||
);
|
||||
anyhow::format_err!(
|
||||
"Failed to run proc-macro server from path {path}, error: {err:?}",
|
||||
)
|
||||
})
|
||||
}))
|
||||
};
|
||||
tracing::info!("Using proc-macro server at {path}");
|
||||
ProcMacroServer::spawn(path.clone()).map_err(|err| {
|
||||
tracing::error!(
|
||||
"Failed to run proc-macro server from path {path}, error: {err:?}",
|
||||
);
|
||||
anyhow::format_err!(
|
||||
"Failed to run proc-macro server from path {path}, error: {err:?}",
|
||||
)
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
let watch = match files_config.watcher {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue