aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-09-17 05:42:14 +0000
committerBlaž Hrastnik2021-09-17 05:43:06 +0000
commit3ff5b001ac721606b68a594958abeee8832a023e (patch)
tree405316eac743b34b285b316dc9f94e52b3dc5a4f
parentc7d6e4461f249108189cddf44b487b4c71c5520a (diff)
fix: Don't allow closing the last split if there's unsaved changes
Fixes #674
-rw-r--r--helix-term/src/commands.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 010a6986..d2a838ba 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1568,7 +1568,7 @@ mod cmd {
/// Results an error if there are modified buffers remaining and sets editor error,
/// otherwise returns `Ok(())`
- fn buffers_remaining_impl(editor: &mut Editor) -> anyhow::Result<()> {
+ pub(super) fn buffers_remaining_impl(editor: &mut Editor) -> anyhow::Result<()> {
let modified: Vec<_> = editor
.documents()
.filter(|doc| doc.is_modified())
@@ -4157,6 +4157,12 @@ fn vsplit(cx: &mut Context) {
}
fn wclose(cx: &mut Context) {
+ if cx.editor.tree.views().count() == 1 {
+ if let Err(err) = cmd::buffers_remaining_impl(cx.editor) {
+ cx.editor.set_error(err.to_string());
+ return;
+ }
+ }
let view_id = view!(cx.editor).id;
// close current split
cx.editor.close(view_id, /* close_buffer */ false);