aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-08-09 04:32:04 +0000
committerSkyler Hawthorne2022-10-19 02:31:39 +0000
commite5fd5e2a9c78a3f391cda24cb57d187e248f06d1 (patch)
tree610a3f5f39510ffe8049c80429eee3fc1c56bf30 /helix-term/src/commands
parentfaa00d4cc3de89a89679f6315c0345182929beb2 (diff)
fix panic when view of pending write is closed
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/typed.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index a687b854..fa2ba5e6 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -34,6 +34,7 @@ fn quit(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) ->
buffers_remaining_impl(cx.editor)?
}
+ cx.block_try_flush_writes()?;
cx.editor.close(view!(cx.editor).id);
Ok(())
@@ -518,15 +519,7 @@ fn write_quit(
}
write_impl(cx, args.first(), false)?;
-
- tokio::task::block_in_place(|| helix_lsp::block_on(cx.jobs.finish(Some(cx.editor), None)))?;
-
- let doc = doc_mut!(cx.editor);
-
- tokio::task::block_in_place(|| helix_lsp::block_on(doc.try_flush_saves()))
- .map(|result| result.map(|_| ()))
- .unwrap_or(Ok(()))?;
-
+ cx.block_try_flush_writes()?;
quit(cx, &[], event)
}
@@ -540,6 +533,7 @@ fn force_write_quit(
}
write_impl(cx, args.first(), true)?;
+ cx.block_try_flush_writes()?;
force_quit(cx, &[], event)
}
@@ -613,6 +607,8 @@ fn write_all_impl(
buffers_remaining_impl(cx.editor)?;
}
+ cx.block_try_flush_writes()?;
+
// close all views
let views: Vec<_> = cx.editor.tree.views().map(|(view, _)| view.id).collect();
for view_id in views {
@@ -682,6 +678,7 @@ fn quit_all(
return Ok(());
}
+ cx.block_try_flush_writes()?;
quit_all_impl(cx.editor, false)
}
@@ -710,8 +707,9 @@ fn cquit(
.first()
.and_then(|code| code.parse::<i32>().ok())
.unwrap_or(1);
- cx.editor.exit_code = exit_code;
+ cx.editor.exit_code = exit_code;
+ cx.block_try_flush_writes()?;
quit_all_impl(cx.editor, false)
}