Skip to content

Commit

Permalink
Auto save will not auto format now
Browse files Browse the repository at this point in the history
This behaviour is not configurable
  • Loading branch information
voiceroy committed Feb 11, 2025
1 parent f2d1d31 commit 87195d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
1 change: 0 additions & 1 deletion book/src/editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 11 additions & 28 deletions helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
3 changes: 0 additions & 3 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 87195d6

Please sign in to comment.