Skip to content

Commit fac6a64

Browse files
committed
Auto merge of #12804 - jonas-schievink:config-watcher, r=Veykril
fix: make file watcher config a drop-down (and clarify the options) Fixes #12794 Also renames "notify" to "server", since that's clearer ("notify" is still accepted for compatibility).
2 parents 22e53f1 + ec1142c commit fac6a64

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

Diff for: crates/rust-analyzer/src/config.rs

+22-7
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ config_data! {
213213
/// also need to add the folders to Code's `files.watcherExclude`.
214214
files_excludeDirs: Vec<PathBuf> = "[]",
215215
/// Controls file watching implementation.
216-
files_watcher: String = "\"client\"",
216+
files_watcher: FilesWatcherDef = "\"client\"",
217217

218218
/// Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.
219219
highlightRelated_breakPoints_enable: bool = "true",
@@ -524,7 +524,7 @@ pub struct FilesConfig {
524524
#[derive(Debug, Clone)]
525525
pub enum FilesWatcher {
526526
Client,
527-
Notify,
527+
Server,
528528
}
529529

530530
#[derive(Debug, Clone)]
@@ -903,12 +903,11 @@ impl Config {
903903

904904
pub fn files(&self) -> FilesConfig {
905905
FilesConfig {
906-
watcher: match self.data.files_watcher.as_str() {
907-
"notify" => FilesWatcher::Notify,
908-
"client" if self.did_change_watched_files_dynamic_registration() => {
906+
watcher: match self.data.files_watcher {
907+
FilesWatcherDef::Client if self.did_change_watched_files_dynamic_registration() => {
909908
FilesWatcher::Client
910909
}
911-
_ => FilesWatcher::Notify,
910+
_ => FilesWatcher::Server,
912911
},
913912
exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
914913
}
@@ -1423,7 +1422,7 @@ enum ManifestOrProjectJson {
14231422

14241423
#[derive(Deserialize, Debug, Clone)]
14251424
#[serde(rename_all = "snake_case")]
1426-
pub enum ExprFillDefaultDef {
1425+
enum ExprFillDefaultDef {
14271426
Todo,
14281427
Default,
14291428
}
@@ -1486,6 +1485,14 @@ enum ReborrowHintsDef {
14861485
Mutable,
14871486
}
14881487

1488+
#[derive(Deserialize, Debug, Clone)]
1489+
#[serde(rename_all = "snake_case")]
1490+
enum FilesWatcherDef {
1491+
Client,
1492+
Notify,
1493+
Server,
1494+
}
1495+
14891496
#[derive(Deserialize, Debug, Clone)]
14901497
#[serde(rename_all = "snake_case")]
14911498
enum ImportPrefixDef {
@@ -1843,6 +1850,14 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
18431850
"Show only the parameters."
18441851
],
18451852
},
1853+
"FilesWatcherDef" => set! {
1854+
"type": "string",
1855+
"enum": ["client", "server"],
1856+
"enumDescriptions": [
1857+
"Use the client (editor) to watch files for changes",
1858+
"Use server-side file watching",
1859+
],
1860+
},
18461861
_ => panic!("missing entry for {}: {}", ty, default),
18471862
}
18481863

Diff for: crates/rust-analyzer/src/reload.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl GlobalState {
320320

321321
let watch = match files_config.watcher {
322322
FilesWatcher::Client => vec![],
323-
FilesWatcher::Notify => project_folders.watch,
323+
FilesWatcher::Server => project_folders.watch,
324324
};
325325
self.vfs_config_version += 1;
326326
self.loader.handle.set_config(vfs::loader::Config {

Diff for: editors/code/package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,15 @@
686686
"rust-analyzer.files.watcher": {
687687
"markdownDescription": "Controls file watching implementation.",
688688
"default": "client",
689-
"type": "string"
689+
"type": "string",
690+
"enum": [
691+
"client",
692+
"server"
693+
],
694+
"enumDescriptions": [
695+
"Use the client (editor) to watch files for changes",
696+
"Use server-side file watching"
697+
]
690698
},
691699
"rust-analyzer.highlightRelated.breakPoints.enable": {
692700
"markdownDescription": "Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.",

0 commit comments

Comments
 (0)