mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
feat: ":write ++p" creates parent dirs #20835
- `:write ++p foo/bar/baz.txt` should create parent directories `foo/bar/` if they do not exist - Note: `:foo ++…` is usually for options. No existing options have a single-char abbreviation (presumably by design), so it's safe to special-case `++p` here. - Same for `writefile(…, 'foo/bar/baz.txt', 'p')` - `BufWriteCmd` can see the ++p flag via `v:cmdarg`. closes #19884
This commit is contained in:
@@ -1922,6 +1922,13 @@ int do_write(exarg_T *eap)
|
||||
fname = curbuf->b_sfname;
|
||||
}
|
||||
|
||||
if (eap->mkdir_p) {
|
||||
if (os_file_mkdir(fname, 0755) < 0) {
|
||||
retval = FAIL;
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
|
||||
name_was_missing = curbuf->b_ffname == NULL;
|
||||
retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
|
||||
eap, eap->append, eap->forceit, true, false);
|
||||
|
Reference in New Issue
Block a user