From cf9ef7377fc50ac9baaac3cf9315c563c5dc9661 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Thu, 15 Aug 2019 17:53:05 -0400 Subject: [PATCH] Don't process modelines after :Gwrite Closes https://github.com/tpope/vim-fugitive/issues/956 --- autoload/fugitive.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index d6902a1..df56407 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1914,6 +1914,8 @@ function! fugitive#FileWriteCmd(...) abort endtry endfunction +let s:nomodeline = (v:version >= 704 ? '' : '') + function! fugitive#BufReadCmd(...) abort let amatch = a:0 ? a:1 : expand('') try @@ -2022,7 +2024,7 @@ function! fugitive#BufReadCmd(...) abort endtry setlocal modifiable - return 'silent doautocmd' . (v:version >= 704 ? ' ' : '') . + return 'silent doautocmd' . s:nomodeline . \ ' BufReadPost' . (modifiable ? '' : '|setl nomodifiable') catch /^fugitive:/ return 'echoerr ' . string(v:exception) @@ -4147,7 +4149,7 @@ function! s:WriteCommand(line1, line2, range, count, bang, mods, reg, arg, args) unlet! restorewinnr let zero = s:Generate(':0:'.file) - silent execute 'doautocmd BufWritePost' s:fnameescape(zero) + silent execute 'doautocmd' s:nomodeline 'BufWritePost' s:fnameescape(zero) for tab in range(1,tabpagenr('$')) for winnr in range(1,tabpagewinnr(tab,'$')) let bufnr = tabpagebuflist(tab)[winnr-1]