SSH Remoting: Fix reload/save race (#19519)
Release Notes: - N/A Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
755fd695f5
commit
bae85d858e
5 changed files with 27 additions and 9 deletions
|
@ -54,7 +54,7 @@ trait BufferStoreImpl {
|
|||
|
||||
fn reload_buffers(
|
||||
&self,
|
||||
buffers: Vec<Model<Buffer>>,
|
||||
buffers: HashSet<Model<Buffer>>,
|
||||
push_to_history: bool,
|
||||
cx: &mut ModelContext<BufferStore>,
|
||||
) -> Task<Result<ProjectTransaction>>;
|
||||
|
@ -392,7 +392,7 @@ impl BufferStoreImpl for Model<RemoteBufferStore> {
|
|||
|
||||
fn reload_buffers(
|
||||
&self,
|
||||
buffers: Vec<Model<Buffer>>,
|
||||
buffers: HashSet<Model<Buffer>>,
|
||||
push_to_history: bool,
|
||||
cx: &mut ModelContext<BufferStore>,
|
||||
) -> Task<Result<ProjectTransaction>> {
|
||||
|
@ -938,7 +938,7 @@ impl BufferStoreImpl for Model<LocalBufferStore> {
|
|||
|
||||
fn reload_buffers(
|
||||
&self,
|
||||
buffers: Vec<Model<Buffer>>,
|
||||
buffers: HashSet<Model<Buffer>>,
|
||||
push_to_history: bool,
|
||||
cx: &mut ModelContext<BufferStore>,
|
||||
) -> Task<Result<ProjectTransaction>> {
|
||||
|
@ -1894,13 +1894,10 @@ impl BufferStore {
|
|||
push_to_history: bool,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<ProjectTransaction>> {
|
||||
let buffers: Vec<Model<Buffer>> = buffers
|
||||
.into_iter()
|
||||
.filter(|buffer| buffer.read(cx).is_dirty())
|
||||
.collect();
|
||||
if buffers.is_empty() {
|
||||
return Task::ready(Ok(ProjectTransaction::default()));
|
||||
}
|
||||
|
||||
self.state.reload_buffers(buffers, push_to_history, cx)
|
||||
}
|
||||
|
||||
|
|
|
@ -2312,6 +2312,12 @@ impl Project {
|
|||
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
match event {
|
||||
BufferEvent::ReloadNeeded => {
|
||||
if !self.is_via_collab() {
|
||||
self.reload_buffers([buffer.clone()].into_iter().collect(), false, cx)
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
BufferEvent::Operation {
|
||||
operation,
|
||||
is_local: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue