From 6d0df81732f64c5abba845c9d5b2bd93f7548806 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 25 Jul 2018 02:53:26 -0400 Subject: [PATCH] Run correct auto-commands for BufWrite and FileWrite --- autoload/fugitive.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 344d3d2..6f2d560 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2789,6 +2789,10 @@ endfunction function! fugitive#FileWriteCmd(...) abort let tmp = tempname() let amatch = a:0 ? a:1 : expand('') + let autype = a:0 > 1 ? 'Buf' : 'File' + if exists('#' . autype . 'WritePre') + execute 'doautocmd ' . autype . 'WritePre ' . s:fnameescape(amatch) + endif try let [dir, commit, file] = s:DirCommitFile(amatch) if commit !~# '^[0-3]$' || !v:cmdbang && (line("'[") != 1 || line("']") != line('$')) @@ -2809,8 +2813,8 @@ function! fugitive#FileWriteCmd(...) abort endif if v:shell_error == 0 setlocal nomodified - if exists('#BufWritePost') - execute 'doautocmd BufWritePost '.s:fnameescape(expand('%:p')) + if exists('#' . autype . 'WritePost') + execute 'doautocmd ' . autype . 'WritePost ' . s:fnameescape(amatch) endif call fugitive#ReloadStatus() return '' @@ -2913,7 +2917,7 @@ function! fugitive#BufReadCmd(...) abort endfunction function! fugitive#BufWriteCmd(...) abort - return call('fugitive#FileWriteCmd', a:000) + return fugitive#FileWriteCmd(a:0 ? a:1 : expand(''), 1) endfunction function! fugitive#SourceCmd(...) abort