aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-04 08:11:13 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-04 08:11:13 +1200
commitea4711603129bc0b780675704fb41c65e9dcba6a (patch)
treec39496cf2fc336e34c059e5522cda104bec17b4b
parentMerge branch 'hotfix/v2.0.2' into develop (diff)
downloadvim-write-mkpath-ea4711603129bc0b780675704fb41c65e9dcba6a.tar.gz
vim-write-mkpath-ea4711603129bc0b780675704fb41c65e9dcba6a.zip
Don't rename buffer if directory creation failed
-rw-r--r--autoload/write_mkpath.vim9
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 %