From 63962f2fcece60e0ac6c7fc413e878e6c7ef1e9d Mon Sep 17 00:00:00 2001 From: KexinLu Date: Wed, 23 Aug 2017 21:53:05 -0700 Subject: [PATCH] Issue #4 Broken File Permissions during Usage Cause: we make a copy of the file then format the copied file, but this file's owner ship and permission are not preserved. Solution: overwrite file content of current file directly --- autoload/phpfmt/fmt.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/phpfmt/fmt.vim b/autoload/phpfmt/fmt.vim index 9cf5973..6488b3d 100644 --- a/autoload/phpfmt/fmt.vim +++ b/autoload/phpfmt/fmt.vim @@ -56,7 +56,11 @@ function! phpfmt#fmt#format() abort "{{{ try | silent undojoin | catch | endtry " reload buffer let old_fileformat = &fileformat - call rename(l:tmpname, expand('%')) + let formatted_content = readfile(l:tmpname) + " copy the content from formatted tempfile + call writefile(formatted_content, expand('%')) + " delete tempfile + call delete(l:tmpname) silent edit! let &fileformat = old_fileformat let &syntax = &syntax