From fe28e470cdf7d864fb69411e780b1e9791d6742a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 21 Mar 2024 21:22:49 +0100 Subject: [PATCH] Use relative glob patterns in DidChangeWatchedFilesRegistrationOptions --- crates/rust-analyzer/src/reload.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 7c7f5aa5ca..0214be006e 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -436,16 +436,19 @@ impl GlobalState { .flat_map(|ws| ws.to_roots()) .filter(|it| it.is_local) .flat_map(|root| { - root.include.into_iter().flat_map(|it| { - [ - format!("{it}/**/*.rs"), - format!("{it}/**/Cargo.toml"), - format!("{it}/**/Cargo.lock"), - ] - }) + root.include + .into_iter() + .flat_map(|it| [(it.clone(), "**/*.rs"), (it, "**/Cargo.{lock,toml}")]) }) - .map(|glob_pattern| lsp_types::FileSystemWatcher { - glob_pattern: lsp_types::GlobPattern::String(glob_pattern), + .map(|(base, pat)| lsp_types::FileSystemWatcher { + glob_pattern: lsp_types::GlobPattern::Relative( + lsp_types::RelativePattern { + base_uri: lsp_types::OneOf::Right( + lsp_types::Url::from_file_path(base).unwrap(), + ), + pattern: pat.to_owned(), + }, + ), kind: None, }) .collect(),