Handle buffer diff base updates and file renames properly for SSH projects (#14989)

Release Notes:

- N/A

---------

Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Max Brunsfeld 2024-07-23 11:32:37 -07:00 committed by GitHub
parent ec093c390f
commit 38e3182bef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 1021 additions and 811 deletions

View file

@ -1,26 +1,25 @@
use std::time::Duration;
use futures::{channel::oneshot, FutureExt};
use gpui::{ModelContext, Task};
use std::{marker::PhantomData, time::Duration};
use crate::Project;
pub struct DebouncedDelay {
pub struct DebouncedDelay<E: 'static> {
task: Option<Task<()>>,
cancel_channel: Option<oneshot::Sender<()>>,
_phantom_data: PhantomData<E>,
}
impl DebouncedDelay {
pub fn new() -> DebouncedDelay {
DebouncedDelay {
impl<E: 'static> DebouncedDelay<E> {
pub fn new() -> Self {
Self {
task: None,
cancel_channel: None,
_phantom_data: PhantomData,
}
}
pub fn fire_new<F>(&mut self, delay: Duration, cx: &mut ModelContext<Project>, func: F)
pub fn fire_new<F>(&mut self, delay: Duration, cx: &mut ModelContext<E>, func: F)
where
F: 'static + Send + FnOnce(&mut Project, &mut ModelContext<Project>) -> Task<()>,
F: 'static + Send + FnOnce(&mut E, &mut ModelContext<E>) -> Task<()>,
{
if let Some(channel) = self.cancel_channel.take() {
_ = channel.send(());