internal: Don't eagerly try to read crate root file contents before VFS
This commit is contained in:
parent
399dbc074b
commit
7b91d01360
@ -307,17 +307,19 @@ impl GlobalState {
|
|||||||
for file in changed_files {
|
for file in changed_files {
|
||||||
let vfs_path = vfs.file_path(file.file_id);
|
let vfs_path = vfs.file_path(file.file_id);
|
||||||
if let Some(path) = vfs_path.as_path() {
|
if let Some(path) = vfs_path.as_path() {
|
||||||
let path = path.to_path_buf();
|
has_structure_changes = file.is_created_or_deleted();
|
||||||
if reload::should_refresh_for_change(&path, file.kind()) {
|
|
||||||
workspace_structure_change = Some((path.clone(), false));
|
if file.is_modified() && path.extension() == Some("rs") {
|
||||||
}
|
|
||||||
if file.is_created_or_deleted() {
|
|
||||||
has_structure_changes = true;
|
|
||||||
workspace_structure_change =
|
|
||||||
Some((path, self.crate_graph_file_dependencies.contains(vfs_path)));
|
|
||||||
} else if path.extension() == Some("rs".as_ref()) {
|
|
||||||
modified_rust_files.push(file.file_id);
|
modified_rust_files.push(file.file_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let path = path.to_path_buf();
|
||||||
|
if file.is_created_or_deleted() {
|
||||||
|
workspace_structure_change.get_or_insert((path, false)).1 |=
|
||||||
|
self.crate_graph_file_dependencies.contains(vfs_path);
|
||||||
|
} else if reload::should_refresh_for_change(&path, file.kind()) {
|
||||||
|
workspace_structure_change.get_or_insert((path.clone(), false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear native diagnostics when their file gets deleted
|
// Clear native diagnostics when their file gets deleted
|
||||||
|
@ -528,21 +528,11 @@ impl GlobalState {
|
|||||||
let (crate_graph, proc_macro_paths, layouts, toolchains) = {
|
let (crate_graph, proc_macro_paths, layouts, toolchains) = {
|
||||||
// Create crate graph from all the workspaces
|
// Create crate graph from all the workspaces
|
||||||
let vfs = &mut self.vfs.write().0;
|
let vfs = &mut self.vfs.write().0;
|
||||||
let loader = &mut self.loader;
|
|
||||||
|
|
||||||
let load = |path: &AbsPath| {
|
let load = |path: &AbsPath| {
|
||||||
let _p = tracing::span!(tracing::Level::DEBUG, "switch_workspaces::load").entered();
|
|
||||||
let vfs_path = vfs::VfsPath::from(path.to_path_buf());
|
let vfs_path = vfs::VfsPath::from(path.to_path_buf());
|
||||||
crate_graph_file_dependencies.insert(vfs_path.clone());
|
crate_graph_file_dependencies.insert(vfs_path.clone());
|
||||||
match vfs.file_id(&vfs_path) {
|
vfs.file_id(&vfs_path)
|
||||||
Some(file_id) => Some(file_id),
|
|
||||||
None => {
|
|
||||||
// FIXME: Consider not loading this here?
|
|
||||||
let contents = loader.handle.load_sync(path);
|
|
||||||
vfs.set_file_contents(vfs_path.clone(), contents);
|
|
||||||
vfs.file_id(&vfs_path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load)
|
ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load)
|
||||||
|
@ -121,6 +121,11 @@ impl ChangedFile {
|
|||||||
matches!(self.change, Change::Create(_) | Change::Delete)
|
matches!(self.change, Change::Create(_) | Change::Delete)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if the change is [`Modify`](ChangeKind::Modify).
|
||||||
|
pub fn is_modified(&self) -> bool {
|
||||||
|
matches!(self.change, Change::Modify(_))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn kind(&self) -> ChangeKind {
|
pub fn kind(&self) -> ChangeKind {
|
||||||
match self.change {
|
match self.change {
|
||||||
Change::Create(_) => ChangeKind::Create,
|
Change::Create(_) => ChangeKind::Create,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user