Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush pending writes before suspend #10797

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ 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) {
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
compositor::Context {
editor: self.editor,
jobs: self.jobs,
scroll: None,
}
.block_try_flush_writes()
.ok();
}
}

#[inline]
Expand Down Expand Up @@ -5826,9 +5838,12 @@ fn shell_prompt(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBeha
);
}

fn suspend(_cx: &mut Context) {
fn suspend(cx: &mut Context) {
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
#[cfg(not(windows))]
signal_hook::low_level::raise(signal_hook::consts::signal::SIGTSTP).unwrap();
{
cx.block_try_flush_writes();
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
signal_hook::low_level::raise(signal_hook::consts::signal::SIGTSTP).unwrap();
}
}

fn add_newline_above(cx: &mut Context) {
Expand Down
Loading