Return back the ability to save non-dirty singleton buffers (#10174)
This commit is contained in:
parent
0861ceaac2
commit
0f1c2e6f2b
1 changed files with 31 additions and 24 deletions
|
@ -705,31 +705,38 @@ impl Item for Editor {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only format and save the buffers with changes. For clean buffers,
|
if buffers.len() == 1 {
|
||||||
// we simulate saving by calling `Buffer::did_save`, so that language servers or
|
// Apply full save routine for singleton buffers, to allow to `touch` the file via the editor.
|
||||||
// other downstream listeners of save events get notified.
|
project
|
||||||
let (dirty_buffers, clean_buffers) = buffers.into_iter().partition(|buffer| {
|
.update(&mut cx, |project, cx| project.save_buffers(buffers, cx))?
|
||||||
buffer
|
.await?;
|
||||||
.update(&mut cx, |buffer, _| {
|
} else {
|
||||||
buffer.is_dirty() || buffer.has_conflict()
|
// For multi-buffers, only format and save the buffers with changes.
|
||||||
})
|
// For clean buffers, we simulate saving by calling `Buffer::did_save`,
|
||||||
.unwrap_or(false)
|
// so that language servers or other downstream listeners of save events get notified.
|
||||||
});
|
let (dirty_buffers, clean_buffers) = buffers.into_iter().partition(|buffer| {
|
||||||
|
buffer
|
||||||
|
.update(&mut cx, |buffer, _| {
|
||||||
|
buffer.is_dirty() || buffer.has_conflict()
|
||||||
|
})
|
||||||
|
.unwrap_or(false)
|
||||||
|
});
|
||||||
|
|
||||||
project
|
project
|
||||||
.update(&mut cx, |project, cx| {
|
.update(&mut cx, |project, cx| {
|
||||||
project.save_buffers(dirty_buffers, cx)
|
project.save_buffers(dirty_buffers, cx)
|
||||||
})?
|
})?
|
||||||
.await?;
|
.await?;
|
||||||
for buffer in clean_buffers {
|
for buffer in clean_buffers {
|
||||||
buffer
|
buffer
|
||||||
.update(&mut cx, |buffer, cx| {
|
.update(&mut cx, |buffer, cx| {
|
||||||
let version = buffer.saved_version().clone();
|
let version = buffer.saved_version().clone();
|
||||||
let fingerprint = buffer.saved_version_fingerprint();
|
let fingerprint = buffer.saved_version_fingerprint();
|
||||||
let mtime = buffer.saved_mtime();
|
let mtime = buffer.saved_mtime();
|
||||||
buffer.did_save(version, fingerprint, mtime, cx);
|
buffer.did_save(version, fingerprint, mtime, cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue