Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add autosave with delay (#11325)

João Miguel Nogueira78f1482cd19a
diff --git a/assets/settings/default.json b/assets/settings/default.json
index f78b82fd0df..14aae816171 100644
--- a/assets/settings/default.json
+++ b/assets/settings/default.json
@@ -349,6 +349,8 @@
// when saving it.
"ensure_final_newline_on_save": true,
// Whether or not to perform a buffer format before saving
+ //
+ // Keep in mind, if the autosave with delay is enabled, format_on_save will be ignored
"format_on_save": "on",
// How to perform a buffer format. This setting can take 4 values:
//
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs
index c048bb84b84..aae840c982c 100644
--- a/crates/workspace/src/pane.rs
+++ b/crates/workspace/src/pane.rs
@@ -1404,8 +1404,15 @@ impl Pane {
project: Model<Project>,
cx: &mut WindowContext,
) -> Task<Result<()>> {
+ let format = if let AutosaveSetting::AfterDelay { .. } =
+ WorkspaceSettings::get_global(cx).autosave
+ {
+ false
+ } else {
+ true
+ };
if Self::can_autosave_item(item, cx) {
- item.save(true, project, cx)
+ item.save(format, project, cx)
} else {
Task::ready(Ok(()))
}