Skip to content

Commit

Permalink
Revert rust-lang#12947, trigger workspace switches on all structure c…
Browse files Browse the repository at this point in the history
…hanges again
  • Loading branch information
Veykril committed Aug 16, 2022
1 parent 8fa8bf1 commit 1f73cbe
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions crates/rust-analyzer/src/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{sync::Arc, time::Instant};
use crossbeam_channel::{unbounded, Receiver, Sender};
use flycheck::FlycheckHandle;
use ide::{Analysis, AnalysisHost, Cancellable, Change, FileId};
use ide_db::base_db::{CrateId, FileLoader, SourceDatabase, SourceDatabaseExt};
use ide_db::base_db::{CrateId, FileLoader, SourceDatabase};
use lsp_types::{SemanticTokens, Url};
use parking_lot::{Mutex, RwLock};
use proc_macro_api::ProcMacroServer;
Expand Down Expand Up @@ -176,9 +176,9 @@ impl GlobalState {

pub(crate) fn process_changes(&mut self) -> bool {
let _p = profile::span("GlobalState::process_changes");
let mut fs_refresh_changes = Vec::new();
// A file was added or deleted
let mut has_structure_changes = false;
let mut workspace_structure_change = None;

let (change, changed_files) = {
let mut change = Change::new();
Expand All @@ -192,7 +192,7 @@ impl GlobalState {
if let Some(path) = vfs.file_path(file.file_id).as_path() {
let path = path.to_path_buf();
if reload::should_refresh_for_change(&path, file.change_kind) {
fs_refresh_changes.push((path, file.file_id));
workspace_structure_change = Some(path);
}
if file.is_created_or_deleted() {
has_structure_changes = true;
Expand Down Expand Up @@ -227,11 +227,10 @@ impl GlobalState {

{
let raw_database = self.analysis_host.raw_database();
let workspace_structure_change =
fs_refresh_changes.into_iter().find(|&(_, file_id)| {
!raw_database.source_root(raw_database.file_source_root(file_id)).is_library
});
if let Some((path, _)) = workspace_structure_change {
// FIXME: ideally we should only trigger a workspace fetch for non-library changes
// but somethings going wrong with the source root business when we add a new local
// crate see https://github.com/rust-lang/rust-analyzer/issues/13029
if let Some(path) = workspace_structure_change {
self.fetch_workspaces_queue
.request_op(format!("workspace vfs file change: {}", path.display()));
}
Expand Down

0 comments on commit 1f73cbe

Please sign in to comment.