From b1a993964b367db4b9399e3e672e82d5bb40d0e3 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 5 Jan 2019 01:43:59 -0500 Subject: [PATCH] Fix commit maps while accommodating bad modelines We need modifiable off for the maps to kick in, but we need to turn it back off before the doautocmd or else it will throw an error if the modeline modifies the buffer with an option like fileencoding, which you should never do, stop doing it. --- autoload/fugitive.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 11f46a2..15b5b33 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1718,16 +1718,17 @@ function! fugitive#BufReadCmd(...) abort if &bufhidden ==# '' setlocal bufhidden=delete endif + let &modifiable = modifiable if b:fugitive_type !=# 'blob' setlocal filetype=git foldmethod=syntax nnoremap a :let b:fugitive_display_format += v:count1exe fugitive#BufReadCmd(@%) nnoremap i :let b:fugitive_display_format -= v:count1exe fugitive#BufReadCmd(@%) else - let &modifiable = modifiable call fugitive#MapJumps() endif endtry + setlocal modifiable return 'silent doautocmd' . (v:version >= 704 ? ' ' : '') . \ ' BufReadPost' . (modifiable ? '' : '|setl nomodifiable') catch /^fugitive:/