Mercurial > forks > helix
changeset 5788:53a198a4dbd6
Flush pending writes before suspend (#10797)
* flush saves before suspending
* review suggestion
Co-authored-by: Kirawi <[email protected]>
* review changes
---------
Co-authored-by: PotatoesFall <[email protected]>
Co-authored-by: Kirawi <[email protected]>
author | Marty <58218546+PotatoesFall@users.noreply.github.com> |
---|---|
date | Wed, 05 Jun 2024 18:47:15 +0200 |
parents | 0fe3d21d5fc0 |
children | 16ec9cc45eab |
files | helix-term/src/commands.rs |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/helix-term/src/commands.rs Tue Jun 04 10:28:17 2024 +0900 +++ b/helix-term/src/commands.rs Wed Jun 05 18:47:15 2024 +0200 @@ -142,6 +142,17 @@ pub fn count(&self) -> usize { self.count.map_or(1, |v| v.get()) } + + /// Waits on all pending jobs, and then tries to flush all pending write + /// operations for all documents. + pub fn block_try_flush_writes(&mut self) -> anyhow::Result<()> { + compositor::Context { + editor: self.editor, + jobs: self.jobs, + scroll: None, + } + .block_try_flush_writes() + } } #[inline] @@ -5828,7 +5839,10 @@ fn suspend(_cx: &mut Context) { #[cfg(not(windows))] - signal_hook::low_level::raise(signal_hook::consts::signal::SIGTSTP).unwrap(); + { + _cx.block_try_flush_writes().ok(); + signal_hook::low_level::raise(signal_hook::consts::signal::SIGTSTP).unwrap(); + } } fn add_newline_above(cx: &mut Context) {