diff options
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 8 |
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), }, |