From ce25aa951e4bd4352fc211258014557e69cc5c5c Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 1 Jun 2021 14:47:21 +0900 Subject: Allow setting a filepath on :write --- helix-term/src/commands.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'helix-term/src') 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), }, -- cgit v1.2.3-70-g09d2