aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorCharlie Groves2022-10-21 01:35:02 +0000
committerGitHub2022-10-21 01:35:02 +0000
commit7e29ee6daeb86fbd20a8b5eaae30b2e0f868147d (patch)
tree07babf558f7aea19346e49f2cdb5862ed62489ca /helix-term/src/ui
parent4ff5feeb0c6c1ce012aa1179a44f35b6f0df4da1 (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')
-rw-r--r--helix-term/src/ui/editor.rs10
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)
+ }
}
}