zed/crates/worktree
Piotr Osiewicz a850731b0e
lsp: Watch paths outside of worktrees at language servers request (#17173)
Context: https://x.com/fasterthanlime/status/1819120238228570598

Up to this PR:
- We were not watching paths outside of a worktree when language server
requested it.
- We expected GlobPattern used for file watching to be always rooted at
the worktree root.

'1 mattered for observing global files (e.g. global RA config) and both
points had impact on "monorepos".
Let's picture the following scenario:
You're working on a Rust project that has two crates: bin and lib crate:
```
my-rust-project/
  bin-crate/
  lib-crate/
```
Up to this PR, making changes like changing field visibility in
lib-crate **was not reflected** in bin-crate until RA was restarted. RA
for bin-crate asked us to watch lib-crate. Now, depending on if you had
this project open as:
- a project with one worktree rooted at my-rust-project:
- due to '2, we never noticed that we have to notify RA instance for
bin-crate about changes in lib-crate.
- a project with two worktrees (bin-crate and lib-crate):
- due to '1 (as lib-crate is not within bin-crate's worktree), we once
again missed the fact that we have to watch for changes in lib-crate.

This PR solves this by introducing a side-channel - we just store fs
watchers for abs paths at the Project level. Worktree changes handling
is left relatively untouched - as it's used for other changes besides
LSP change notifying, I've figured to better leave it as is, as right
now we have 1 worktree change watcher; if we were to change it, we'd
have `(language server) + 1` watchers per worktree, which seems.. pretty
horrid.

What's the end effect? At the very least fasterthanlime should be a tad
happier; in reality though, I expect it to have some impact on LS
reliability in monorepo setups.

TODO
- [x] Wire through FileChangeType into `fs::watch` interface.

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.
2024-08-31 01:32:33 +02:00
..
src lsp: Watch paths outside of worktrees at language servers request (#17173) 2024-08-31 01:32:33 +02:00
Cargo.toml project search: Increase perf up to 10x by batching git status calls (#16936) 2024-08-27 11:59:59 +02:00
LICENSE-GPL Rename 'project_core' crate to 'worktree', make it just about worktrees (#9189) 2024-03-11 11:35:27 -07:00