mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-16 07:13:52 -05:00
Run correct auto-commands for BufWrite and FileWrite
This commit is contained in:
@@ -2789,6 +2789,10 @@ endfunction
|
|||||||
function! fugitive#FileWriteCmd(...) abort
|
function! fugitive#FileWriteCmd(...) abort
|
||||||
let tmp = tempname()
|
let tmp = tempname()
|
||||||
let amatch = a:0 ? a:1 : expand('<amatch>')
|
let amatch = a:0 ? a:1 : expand('<amatch>')
|
||||||
|
let autype = a:0 > 1 ? 'Buf' : 'File'
|
||||||
|
if exists('#' . autype . 'WritePre')
|
||||||
|
execute 'doautocmd ' . autype . 'WritePre ' . s:fnameescape(amatch)
|
||||||
|
endif
|
||||||
try
|
try
|
||||||
let [dir, commit, file] = s:DirCommitFile(amatch)
|
let [dir, commit, file] = s:DirCommitFile(amatch)
|
||||||
if commit !~# '^[0-3]$' || !v:cmdbang && (line("'[") != 1 || line("']") != line('$'))
|
if commit !~# '^[0-3]$' || !v:cmdbang && (line("'[") != 1 || line("']") != line('$'))
|
||||||
@@ -2809,8 +2813,8 @@ function! fugitive#FileWriteCmd(...) abort
|
|||||||
endif
|
endif
|
||||||
if v:shell_error == 0
|
if v:shell_error == 0
|
||||||
setlocal nomodified
|
setlocal nomodified
|
||||||
if exists('#BufWritePost')
|
if exists('#' . autype . 'WritePost')
|
||||||
execute 'doautocmd BufWritePost '.s:fnameescape(expand('%:p'))
|
execute 'doautocmd ' . autype . 'WritePost ' . s:fnameescape(amatch)
|
||||||
endif
|
endif
|
||||||
call fugitive#ReloadStatus()
|
call fugitive#ReloadStatus()
|
||||||
return ''
|
return ''
|
||||||
@@ -2913,7 +2917,7 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#BufWriteCmd(...) abort
|
function! fugitive#BufWriteCmd(...) abort
|
||||||
return call('fugitive#FileWriteCmd', a:000)
|
return fugitive#FileWriteCmd(a:0 ? a:1 : expand('<amatch>'), 1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#SourceCmd(...) abort
|
function! fugitive#SourceCmd(...) abort
|
||||||
|
|||||||
Reference in New Issue
Block a user