Skip to content

Commit baa2ccc

Browse files
committed
Auto merge of #13038 - Veykril:rev-12947, r=Veykril
Revert #12947, trigger workspace switches on all structure changes again Closes #13029
2 parents 8fa8bf1 + 1f73cbe commit baa2ccc

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

crates/rust-analyzer/src/global_state.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{sync::Arc, time::Instant};
88
use crossbeam_channel::{unbounded, Receiver, Sender};
99
use flycheck::FlycheckHandle;
1010
use ide::{Analysis, AnalysisHost, Cancellable, Change, FileId};
11-
use ide_db::base_db::{CrateId, FileLoader, SourceDatabase, SourceDatabaseExt};
11+
use ide_db::base_db::{CrateId, FileLoader, SourceDatabase};
1212
use lsp_types::{SemanticTokens, Url};
1313
use parking_lot::{Mutex, RwLock};
1414
use proc_macro_api::ProcMacroServer;
@@ -176,9 +176,9 @@ impl GlobalState {
176176

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

183183
let (change, changed_files) = {
184184
let mut change = Change::new();
@@ -192,7 +192,7 @@ impl GlobalState {
192192
if let Some(path) = vfs.file_path(file.file_id).as_path() {
193193
let path = path.to_path_buf();
194194
if reload::should_refresh_for_change(&path, file.change_kind) {
195-
fs_refresh_changes.push((path, file.file_id));
195+
workspace_structure_change = Some(path);
196196
}
197197
if file.is_created_or_deleted() {
198198
has_structure_changes = true;
@@ -227,11 +227,10 @@ impl GlobalState {
227227

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

0 commit comments

Comments
 (0)