Skip to content

Commit

Permalink
Flush pending writes before suspend (helix-editor#10797)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored and AOx0 committed Jun 15, 2024
1 parent 418ac23 commit 32fe804
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ impl<'a> Context<'a> {
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]
Expand Down Expand Up @@ -5837,7 +5848,10 @@ fn shell_prompt(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBeha

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) {
Expand Down

0 comments on commit 32fe804

Please sign in to comment.