From ea4711603129bc0b780675704fb41c65e9dcba6a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 4 Jun 2019 08:11:13 +1200 Subject: Don't rename buffer if directory creation failed --- autoload/write_mkpath.vim | 9 ++++++--- 1 file 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 % -- cgit v1.2.3