diff options
author | Charlie Groves | 2022-10-21 01:35:02 +0000 |
---|---|---|
committer | GitHub | 2022-10-21 01:35:02 +0000 |
commit | 7e29ee6daeb86fbd20a8b5eaae30b2e0f868147d (patch) | |
tree | 07babf558f7aea19346e49f2cdb5862ed62489ca /helix-term/src/ui/editor.rs | |
parent | 4ff5feeb0c6c1ce012aa1179a44f35b6f0df4da1 (diff) |
Autosave all when the terminal loses focus (#3178)
* Autosave all when the terminal loses focus
* Correct comment on focus config
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Need a block_try_flush_writes in all quit_all paths
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r-- | helix-term/src/ui/editor.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 73dfd52c..43b1e7a0 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1426,7 +1426,15 @@ impl Component for EditorView { Event::Mouse(event) => self.handle_mouse_event(event, &mut cx), Event::IdleTimeout => self.handle_idle_timeout(&mut cx), - Event::FocusGained | Event::FocusLost => EventResult::Ignored(None), + Event::FocusGained => EventResult::Ignored(None), + Event::FocusLost => { + if context.editor.config().auto_save { + if let Err(e) = commands::typed::write_all_impl(context, false, false) { + context.editor.set_error(format!("{}", e)); + } + } + EventResult::Consumed(None) + } } } |