diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-04 08:11:13 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-04 08:11:13 +1200 |
commit | ea4711603129bc0b780675704fb41c65e9dcba6a (patch) | |
tree | c39496cf2fc336e34c059e5522cda104bec17b4b /autoload/write_mkpath.vim | |
parent | Merge branch 'hotfix/v2.0.2' into develop (diff) | |
download | vim-write-mkpath-ea4711603129bc0b780675704fb41c65e9dcba6a.tar.gz vim-write-mkpath-ea4711603129bc0b780675704fb41c65e9dcba6a.zip |
Don't rename buffer if directory creation failed
Diffstat (limited to 'autoload/write_mkpath.vim')
-rw-r--r-- | autoload/write_mkpath.vim | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/autoload/write_mkpath.vim b/autoload/write_mkpath.vim index cba56e9..95fab08 100644 --- a/autoload/write_mkpath.vim +++ b/autoload/write_mkpath.vim @@ -21,11 +21,14 @@ 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 % |