Drag detached files towards loading

This commit is contained in:
Kirill Bulatov
2021-05-23 20:56:54 +03:00
parent 695569d978
commit de090749d9
6 changed files with 83 additions and 11 deletions

View File

@@ -236,7 +236,7 @@ impl Default for ConfigData {
pub struct Config {
caps: lsp_types::ClientCapabilities,
data: ConfigData,
detached_files: Vec<ProjectManifest>,
detached_files: Vec<AbsPathBuf>,
pub discovered_projects: Option<Vec<ProjectManifest>>,
pub root_path: AbsPathBuf,
}
@@ -345,7 +345,6 @@ impl Config {
self.detached_files = get_field::<Vec<PathBuf>>(&mut json, "detachedFiles", None, "[]")
.into_iter()
.map(AbsPathBuf::assert)
.map(ProjectManifest::DetachedFile)
.collect();
self.data = ConfigData::from_json(json);
}
@@ -399,7 +398,7 @@ impl Config {
}
}
pub fn detached_files(&self) -> &[ProjectManifest] {
pub fn detached_files(&self) -> &[AbsPathBuf] {
&self.detached_files
}

View File

@@ -312,6 +312,7 @@ impl GlobalStateSnapshot {
cargo.target_by_root(&path).map(|it| (cargo, it))
}
ProjectWorkspace::Json { .. } => None,
ProjectWorkspace::DetachedFiles { .. } => None,
})
}
}

View File

@@ -146,8 +146,8 @@ impl GlobalState {
log::info!("will fetch workspaces");
self.task_pool.handle.spawn_with_sender({
// TODO kb reload workspace here?
let linked_projects = self.config.linked_projects();
let detached_files = self.config.detached_files().to_vec();
let cargo_config = self.config.cargo();
move |sender| {
@@ -162,7 +162,7 @@ impl GlobalState {
sender.send(Task::FetchWorkspace(ProjectWorkspaceProgress::Begin)).unwrap();
let workspaces = linked_projects
let mut workspaces = linked_projects
.iter()
.map(|project| match project {
LinkedProject::ProjectManifest(manifest) => {
@@ -181,6 +181,11 @@ impl GlobalState {
})
.collect::<Vec<_>>();
if !detached_files.is_empty() {
workspaces
.push(project_model::ProjectWorkspace::load_detached_files(detached_files));
}
log::info!("did fetch workspaces {:?}", workspaces);
sender
.send(Task::FetchWorkspace(ProjectWorkspaceProgress::End(workspaces)))
@@ -408,6 +413,7 @@ impl GlobalState {
_ => None,
}
}
ProjectWorkspace::DetachedFiles { .. } => None,
})
.map(|(id, root)| {
let sender = sender.clone();