mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 03:53:47 -05:00
Recreate temp directory if it gets deleted
Vim does not check the existence of its temp directory when generating file names with tempname(). Therefore if, for some reason, the temp directory gets deleted, Vim will continue to generate paths for file names inside the directory. Writes to these file paths will fail (E482). See #746, #433, #190, #147.
This commit is contained in:
@@ -399,7 +399,16 @@ function! s:write_buffer(bufnr, file)
|
|||||||
let bufcontents[0]=''.bufcontents[0]
|
let bufcontents[0]=''.bufcontents[0]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" The file we are writing to is a temporary file. Sometimes the parent
|
||||||
|
" directory is deleted outside Vim but, because Vim caches the directory
|
||||||
|
" name at startup and does not check for its existence subsequently, Vim
|
||||||
|
" does not realise. This causes E482 errors.
|
||||||
|
try
|
||||||
call writefile(bufcontents, a:file, 'b')
|
call writefile(bufcontents, a:file, 'b')
|
||||||
|
catch /E482/
|
||||||
|
call mkdir(fnamemodify(a:file, ':h'), '', '0700')
|
||||||
|
call writefile(bufcontents, a:file, 'b')
|
||||||
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user