Trigger formatting effects when saving unmodified singleton buffers (#32603)
Closes https://github.com/zed-industries/zed/issues/12091 Use `"save_non_dirty_buffers": false` editor settings to disable this behavior. Release Notes: - Fixed formatting effects not triggered when saving unmodified singleton buffers
This commit is contained in:
parent
7ecad2bef9
commit
5e07d0f6de
5 changed files with 68 additions and 21 deletions
|
@ -816,22 +816,23 @@ impl Item for Editor {
|
|||
.into_iter()
|
||||
.map(|handle| handle.read(cx).base_buffer().unwrap_or(handle.clone()))
|
||||
.collect::<HashSet<_>>();
|
||||
cx.spawn_in(window, async move |this, cx| {
|
||||
let save_non_dirty_buffers = self.save_non_dirty_buffers(cx);
|
||||
cx.spawn_in(window, async move |editor, cx| {
|
||||
if format {
|
||||
this.update_in(cx, |editor, window, cx| {
|
||||
editor.perform_format(
|
||||
project.clone(),
|
||||
FormatTrigger::Save,
|
||||
FormatTarget::Buffers,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await?;
|
||||
editor
|
||||
.update_in(cx, |editor, window, cx| {
|
||||
editor.perform_format(
|
||||
project.clone(),
|
||||
FormatTrigger::Save,
|
||||
FormatTarget::Buffers,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})?
|
||||
.await?;
|
||||
}
|
||||
|
||||
if buffers.len() == 1 {
|
||||
// Apply full save routine for singleton buffers, to allow to `touch` the file via the editor.
|
||||
if save_non_dirty_buffers {
|
||||
project
|
||||
.update(cx, |project, cx| project.save_buffers(buffers, cx))?
|
||||
.await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue