Skip to content

Commit ea144bc

Browse files
committed
Use relative glob patterns in DidChangeWatchedFilesRegistrationOptions
1 parent 23613a9 commit ea144bc

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

crates/rust-analyzer/src/reload.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,27 @@ impl GlobalState {
436436
.flat_map(|ws| ws.to_roots())
437437
.filter(|it| it.is_local)
438438
.flat_map(|root| {
439-
root.include.into_iter().flat_map(|it| {
440-
[
441-
format!("{it}/**/*.rs"),
442-
format!("{it}/**/Cargo.toml"),
443-
format!("{it}/**/Cargo.lock"),
444-
]
445-
})
439+
root.include
440+
.into_iter()
441+
.flat_map(|it| [(it.clone(), "**/*.rs"), (it, "**/Cargo.{lock,toml}")])
446442
})
447-
.map(|glob_pattern| lsp_types::FileSystemWatcher {
448-
glob_pattern: lsp_types::GlobPattern::String(glob_pattern),
443+
.map(|(base, pat)| lsp_types::FileSystemWatcher {
444+
glob_pattern: lsp_types::GlobPattern::Relative(
445+
lsp_types::RelativePattern {
446+
base_uri: lsp_types::OneOf::Right(
447+
lsp_types::Url::from_file_path(&base).unwrap(),
448+
),
449+
pattern: pat.to_owned(),
450+
},
451+
),
449452
kind: None,
450453
})
451454
.collect(),
452455
};
453456
let registration = lsp_types::Registration {
454457
id: "workspace/didChangeWatchedFiles".to_owned(),
455458
method: "workspace/didChangeWatchedFiles".to_owned(),
456-
register_options: Some(serde_json::to_value(registration_options).unwrap()),
459+
register_options: Some(serde_json::to_value(dbg!(registration_options)).unwrap()),
457460
};
458461
self.send_request::<lsp_types::request::RegisterCapability>(
459462
lsp_types::RegistrationParams { registrations: vec![registration] },

0 commit comments

Comments
 (0)