lsp: Watch paths outside of worktrees at language servers request (#17499)

Another stab at https://github.com/zed-industries/zed/pull/17173, this
time fixing the segfault found in
https://github.com/zed-industries/zed/pull/17206

Release Notes:

- Improved language server reliability in multi-worktree projects and
monorepo. We now notify the language server more reliably about which
files have changed.
This commit is contained in:
Piotr Osiewicz 2024-09-06 15:47:17 +02:00 committed by GitHub
parent 938c90fd3b
commit 903f92045a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 446 additions and 102 deletions

View file

@ -1153,13 +1153,13 @@ fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
.await;
while let Some(paths) = events.next().await {
for path in paths {
if fs.metadata(&path).await.ok().flatten().is_some() {
for event in paths {
if fs.metadata(&event.path).await.ok().flatten().is_some() {
if let Some(theme_registry) =
cx.update(|cx| ThemeRegistry::global(cx).clone()).log_err()
{
if let Some(()) = theme_registry
.load_user_theme(&path, fs.clone())
.load_user_theme(&event.path, fs.clone())
.await
.log_err()
{
@ -1188,8 +1188,10 @@ fn watch_languages(fs: Arc<dyn fs::Fs>, languages: Arc<LanguageRegistry>, cx: &m
cx.spawn(|_| async move {
let (mut events, _) = fs.watch(path.as_path(), Duration::from_millis(100)).await;
while let Some(event) = events.next().await {
let has_language_file = event.iter().any(|path| {
path.extension()
let has_language_file = event.iter().any(|event| {
event
.path
.extension()
.map(|ext| ext.to_string_lossy().as_ref() == "scm")
.unwrap_or(false)
});