From 87195d6a5f174e5c568653700b259a7e2e3b11ea Mon Sep 17 00:00:00 2001 From: Harishankar G Date: Tue, 11 Feb 2025 16:59:20 +0530 Subject: [PATCH] Auto save will not auto format now This behaviour is not configurable --- book/src/editor.md | 1 - helix-term/src/commands/typed.rs | 39 +++++++++----------------------- helix-view/src/editor.rs | 3 --- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/book/src/editor.md b/book/src/editor.md index 73389c7504ba..2baa907f9303 100644 --- a/book/src/editor.md +++ b/book/src/editor.md @@ -262,7 +262,6 @@ Control auto save behavior. | `focus-lost` | Enable automatic saving on the focus moving away from Helix. Requires [focus event support](https://github.com/helix-editor/helix/wiki/Terminal-Support) from your terminal | `false` | | `after-delay.enable` | Enable automatic saving after `auto-save.after-delay.timeout` milliseconds have passed since last edit. | `false` | | `after-delay.timeout` | Time in milliseconds since last edit before auto save timer triggers. | `3000` | -| `format-on-auto-save ` | Enable formatting on automatic save. | `false` | ### `[editor.search]` Section diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index e2c03708e0eb..5b3c507382b3 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -723,34 +723,17 @@ pub fn write_all_impl( // Save an undo checkpoint for any outstanding changes. doc.append_changes_to_history(view); - let fmt = if config.auto_format { - if from_auto_save { - if config.auto_save.format_on_auto_save { - doc.auto_format().map(|fmt| { - let callback = make_format_callback( - doc_id, - doc.version(), - target_view, - fmt, - Some((None, force)), - ); - jobs.add(Job::with_callback(callback).wait_before_exiting()); - }) - } else { - None - } - } else { - doc.auto_format().map(|fmt| { - let callback = make_format_callback( - doc_id, - doc.version(), - target_view, - fmt, - Some((None, force)), - ); - jobs.add(Job::with_callback(callback).wait_before_exiting()); - }) - } + let fmt = if config.auto_format && !from_auto_save { + doc.auto_format().map(|fmt| { + let callback = make_format_callback( + doc_id, + doc.version(), + target_view, + fmt, + Some((None, force)), + ); + jobs.add(Job::with_callback(callback).wait_before_exiting()); + }) } else { None }; diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 7b7338fd2185..739dcfb4982d 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -807,9 +807,6 @@ pub struct AutoSave { /// Auto save on focus lost. Defaults to false. #[serde(default)] pub focus_lost: bool, - /// Format on auto save. Defaults to false. - #[serde(default)] - pub format_on_auto_save: bool, } #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]