aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION2
-rw-r--r--autoload/write_mkpath.vim14
-rw-r--r--doc/write_mkpath.txt2
3 files changed, 13 insertions, 5 deletions
diff --git a/VERSION b/VERSION
index e9307ca..7ec1d6d 100644
--- a/VERSION
+++ b/VERSION
@@ -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*