aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs50
1 files changed, 42 insertions, 8 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 8c0a005c..c7aab726 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1700,8 +1700,7 @@ mod cmd {
buffers_remaining_impl(cx.editor)?
}
- cx.editor
- .close(view!(cx.editor).id, /* close_buffer */ false);
+ cx.editor.close(view!(cx.editor).id);
Ok(())
}
@@ -1711,8 +1710,7 @@ mod cmd {
_args: &[&str],
_event: PromptEvent,
) -> anyhow::Result<()> {
- cx.editor
- .close(view!(cx.editor).id, /* close_buffer */ false);
+ cx.editor.close(view!(cx.editor).id);
Ok(())
}
@@ -1730,6 +1728,28 @@ mod cmd {
Ok(())
}
+ fn buffer_close(
+ cx: &mut compositor::Context,
+ _args: &[&str],
+ _event: PromptEvent,
+ ) -> anyhow::Result<()> {
+ let view = view!(cx.editor);
+ let doc_id = view.doc;
+ cx.editor.close_document(doc_id, false)?;
+ Ok(())
+ }
+
+ fn force_buffer_close(
+ cx: &mut compositor::Context,
+ _args: &[&str],
+ _event: PromptEvent,
+ ) -> anyhow::Result<()> {
+ let view = view!(cx.editor);
+ let doc_id = view.doc;
+ cx.editor.close_document(doc_id, true)?;
+ Ok(())
+ }
+
fn write_impl<P: AsRef<Path>>(
cx: &mut compositor::Context,
path: Option<P>,
@@ -1976,7 +1996,7 @@ mod cmd {
// close all views
let views: Vec<_> = cx.editor.tree.views().map(|(view, _)| view.id).collect();
for view_id in views {
- cx.editor.close(view_id, false);
+ cx.editor.close(view_id);
}
}
@@ -2020,7 +2040,7 @@ mod cmd {
// close all views
let views: Vec<_> = editor.tree.views().map(|(view, _)| view.id).collect();
for view_id in views {
- editor.close(view_id, false);
+ editor.close(view_id);
}
Ok(())
@@ -2333,6 +2353,20 @@ mod cmd {
completer: Some(completers::filename),
},
TypableCommand {
+ name: "buffer-close",
+ aliases: &["bc", "bclose"],
+ doc: "Close the current buffer.",
+ fun: buffer_close,
+ completer: None, // FIXME: buffer completer
+ },
+ TypableCommand {
+ name: "buffer-close!",
+ aliases: &["bc!", "bclose!"],
+ doc: "Close the current buffer forcefully (ignoring unsaved changes).",
+ fun: force_buffer_close,
+ completer: None, // FIXME: buffer completer
+ },
+ TypableCommand {
name: "write",
aliases: &["w"],
doc: "Write changes to disk. Accepts an optional path (:write some/path.txt)",
@@ -4914,7 +4948,7 @@ fn wclose(cx: &mut Context) {
}
let view_id = view!(cx.editor).id;
// close current split
- cx.editor.close(view_id, /* close_buffer */ false);
+ cx.editor.close(view_id);
}
fn wonly(cx: &mut Context) {
@@ -4926,7 +4960,7 @@ fn wonly(cx: &mut Context) {
.collect::<Vec<_>>();
for (view_id, focus) in views {
if !focus {
- cx.editor.close(view_id, /* close_buffer */ false);
+ cx.editor.close(view_id);
}
}
}