autosave: Respect project autosave settings per file (#13369)

This fixes #13316 by checking whether there are any local workspace
settings for a given file.

Release Notes:

- Fixed `autosave` settings in project-specific settings file being
ignored. ([#13316](https://github.com/zed-industries/zed/issues/13316)).

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-06-24 14:56:22 +02:00 committed by GitHub
parent 3ee3c6a3bd
commit 40748b0a15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 17 deletions

View file

@ -1421,7 +1421,7 @@ impl Pane {
if save_intent == SaveIntent::Close {
let will_autosave = cx.update(|cx| {
matches!(
WorkspaceSettings::get_global(cx).autosave,
item.workspace_settings(cx).autosave,
AutosaveSetting::OnFocusChange | AutosaveSetting::OnWindowChange
) && Self::can_autosave_item(item, cx)
})?;
@ -1490,13 +1490,12 @@ impl Pane {
project: Model<Project>,
cx: &mut WindowContext,
) -> Task<Result<()>> {
let format = if let AutosaveSetting::AfterDelay { .. } =
WorkspaceSettings::get_global(cx).autosave
{
false
} else {
true
};
let format =
if let AutosaveSetting::AfterDelay { .. } = item.workspace_settings(cx).autosave {
false
} else {
true
};
if Self::can_autosave_item(item, cx) {
item.save(format, project, cx)
} else {