aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-06-01 05:47:21 +0000
committerBlaž Hrastnik2021-06-01 08:26:03 +0000
commitce25aa951e4bd4352fc211258014557e69cc5c5c (patch)
tree7c8d34c6ee95f4f4041c6774c3590ccda6bace3c /helix-term/src
parenta2147fc7d56f9f5cb614d8c80b154a545dd59f00 (diff)
Allow setting a filepath on :write
Diffstat (limited to 'helix-term/src')
-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 c1a07d68..3dba9333 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -898,6 +898,12 @@ mod cmd {
fn write(editor: &mut Editor, args: &[&str], event: PromptEvent) {
let (view, doc) = editor.current();
+ if let Some(path) = args.get(0) {
+ if let Err(err) = doc.set_path(Path::new(path)) {
+ editor.set_error(format!("invalid filepath: {}", err));
+ return;
+ };
+ }
if doc.path().is_none() {
editor.set_error("cannot write a buffer without a filename".to_string());
return;
@@ -941,7 +947,7 @@ mod cmd {
Command {
name: "write",
alias: Some("w"),
- doc: "Write changes to disk.",
+ doc: "Write changes to disk. Accepts an optional path (:write some/path.txt)",
fun: write,
completer: Some(completers::filename),
},