Skip to content

Commit a03cfa4

Browse files
committed
Automatically reload project on config change
1 parent 298adb2 commit a03cfa4

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

crates/ra_project_model/src/project_json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ use serde::{de, Deserialize};
1010
use stdx::split_delim;
1111

1212
/// Roots and crates that compose this Rust project.
13-
#[derive(Clone, Debug)]
13+
#[derive(Clone, Debug, Eq, PartialEq)]
1414
pub struct ProjectJson {
1515
pub(crate) roots: Vec<Root>,
1616
pub(crate) crates: Vec<Crate>,
1717
}
1818

1919
/// A root points to the directory which contains Rust crates. rust-analyzer watches all files in
2020
/// all roots. Roots might be nested.
21-
#[derive(Clone, Debug)]
21+
#[derive(Clone, Debug, Eq, PartialEq)]
2222
pub struct Root {
2323
pub(crate) path: AbsPathBuf,
2424
}
2525

2626
/// A crate points to the root module of a crate and lists the dependencies of the crate. This is
2727
/// useful in creating the crate graph.
28-
#[derive(Clone, Debug)]
28+
#[derive(Clone, Debug, Eq, PartialEq)]
2929
pub struct Crate {
3030
pub(crate) root_module: AbsPathBuf,
3131
pub(crate) edition: Edition,

crates/rust-analyzer/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct Config {
4444
pub root_path: AbsPathBuf,
4545
}
4646

47-
#[derive(Debug, Clone)]
47+
#[derive(Debug, Clone, Eq, PartialEq)]
4848
pub enum LinkedProject {
4949
ProjectManifest(ProjectManifest),
5050
InlineJsonProject(ProjectJson),

crates/rust-analyzer/src/reload.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ impl GlobalState {
1919
if self.config.lru_capacity != old_config.lru_capacity {
2020
self.analysis_host.update_lru_capacity(old_config.lru_capacity);
2121
}
22-
if self.config.flycheck != old_config.flycheck {
22+
if self.config.linked_projects != old_config.linked_projects {
23+
self.reload()
24+
} else if self.config.flycheck != old_config.flycheck {
2325
self.reload_flycheck();
2426
}
2527
}
2628
pub(crate) fn reload(&mut self) {
29+
log::info!("reloading projects: {:?}", self.config.linked_projects);
2730
let workspaces = {
2831
if self.config.linked_projects.is_empty()
2932
&& self.config.notifications.cargo_toml_not_found

0 commit comments

Comments
 (0)