diff options
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | autoload/write_mkpath.vim | 14 | ||||
-rw-r--r-- | doc/write_mkpath.txt | 2 |
3 files changed, 13 insertions, 5 deletions
@@ -1 +1 @@ -2.0.2 +2.1.0 diff --git a/autoload/write_mkpath.vim b/autoload/write_mkpath.vim index cba56e9..7610b87 100644 --- a/autoload/write_mkpath.vim +++ b/autoload/write_mkpath.vim @@ -21,13 +21,21 @@ function! write_mkpath#(path) abort let mkpath = 0 endif - " If we decided to attempt a path creation, do so - if mkpath - call mkdir(dir, 'p') + " Stop here if we're not creating a path + if !mkpath + return endif + " Create the full required path + call mkdir(dir, 'p') + " Prod Vim into realising the buffer's directory exists now, so that a " subsequent change of working directory doesn't break it silent keepalt file % + " Re-run the BufWritePre hooks, now that the directory exists and a useable + " filename has been set; this will start this function again from the top, + " but stop when it sees the directory now exists + doautocmd BufWritePre + endfunction diff --git a/doc/write_mkpath.txt b/doc/write_mkpath.txt index 33aec4d..b300855 100644 --- a/doc/write_mkpath.txt +++ b/doc/write_mkpath.txt @@ -1,4 +1,4 @@ -*write_mkpath.txt* For Vim version 7.2 Last change: 2019 Jun 01 +*write_mkpath.txt* For Vim version 7.2 Last change: 2019 Jun 4 DESCRIPTION *write_mkpath* |