diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-04 08:18:20 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-04 08:18:20 +1200 |
commit | 5c00abcf43f905dd0aefe5d8468a2f46a2fbf6a0 (patch) | |
tree | 92277591a545410fb21a53e7f429e04f5c589deb | |
parent | Merge branch 'hotfix/v2.0.2' (diff) | |
parent | Bump VERSION (diff) | |
download | vim-write-mkpath-5c00abcf43f905dd0aefe5d8468a2f46a2fbf6a0.tar.gz vim-write-mkpath-5c00abcf43f905dd0aefe5d8468a2f46a2fbf6a0.zip |
Merge branch 'release/v2.1.0'v2.1.0
* release/v2.1.0:
Re-run BufWritePre hooks after successful rename
Don't rename buffer if directory creation failed
-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* |