Add autosave with delay (#11325)
Implemented autosave functionality with a delay, which now refrains from formatting the code upon triggering unless the user manually saves it. Additionally, enhanced documentation for the `format_on_save` setting has been added. This resolves the issue where autosave with delay would inadvertently format the code, disrupting the user experience, as reported in the corresponding issue. Release Notes: - Fixed a bug where autosave after_delay would auto-format the buffer ([#9787](https://github.com/zed-industries/zed/issues/9787)). --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
9fdfe5c813
commit
78f1482cd1
2 changed files with 10 additions and 1 deletions
|
@ -349,6 +349,8 @@
|
||||||
// when saving it.
|
// when saving it.
|
||||||
"ensure_final_newline_on_save": true,
|
"ensure_final_newline_on_save": true,
|
||||||
// Whether or not to perform a buffer format before saving
|
// 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",
|
"format_on_save": "on",
|
||||||
// How to perform a buffer format. This setting can take 4 values:
|
// How to perform a buffer format. This setting can take 4 values:
|
||||||
//
|
//
|
||||||
|
|
|
@ -1404,8 +1404,15 @@ impl Pane {
|
||||||
project: Model<Project>,
|
project: Model<Project>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
|
let format = if let AutosaveSetting::AfterDelay { .. } =
|
||||||
|
WorkspaceSettings::get_global(cx).autosave
|
||||||
|
{
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
};
|
||||||
if Self::can_autosave_item(item, cx) {
|
if Self::can_autosave_item(item, cx) {
|
||||||
item.save(true, project, cx)
|
item.save(format, project, cx)
|
||||||
} else {
|
} else {
|
||||||
Task::ready(Ok(()))
|
Task::ready(Ok(()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue