zed: Mark restored buffers as conflicted if file changed on disk between store & restore (#15207)

Previously, we've only marked restored buffers as dirty. This PR changes
that behavior in case the buffer has been associated with a file and
that file has changed on disk since the last time Zed stored its
contents.

Example timeline:

1. User edits file in Zed, buffer is dirty
2. User quites Zed with `cmd-q`
3. User changes file on disk: `echo foobar >> file.txt` or `git checkout
file.txt`
4. User starts Zed
5. File/buffer are now marked as having a conflict (yellow icon)

Release Notes:

- Unsaved files that are restored when Zed starts are now marked as
having a conflict if they have been changed on disk since the last time
they were stored.

Demo:



https://github.com/user-attachments/assets/6098b485-b325-49b7-b694-fd2fc60cce64
This commit is contained in:
Thorsten Ball 2024-07-25 18:04:47 +02:00 committed by GitHub
parent 6d3eaa055f
commit 7146087b44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 447 additions and 120 deletions

View file

@ -821,6 +821,11 @@ impl FakeFs {
})
}
pub fn set_next_mtime(&self, next_mtime: SystemTime) {
let mut state = self.state.lock();
state.next_mtime = next_mtime;
}
pub async fn insert_file(&self, path: impl AsRef<Path>, content: Vec<u8>) {
self.write_file_internal(path, content).unwrap()
}