mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -05:00
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.
This commit is contained in:
@@ -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 <buffer> <silent> a :<C-U>let b:fugitive_display_format += v:count1<Bar>exe fugitive#BufReadCmd(@%)<CR>
|
||||
nnoremap <buffer> <silent> i :<C-U>let b:fugitive_display_format -= v:count1<Bar>exe fugitive#BufReadCmd(@%)<CR>
|
||||
else
|
||||
let &modifiable = modifiable
|
||||
call fugitive#MapJumps()
|
||||
endif
|
||||
endtry
|
||||
|
||||
setlocal modifiable
|
||||
return 'silent doautocmd' . (v:version >= 704 ? ' <nomodeline>' : '') .
|
||||
\ ' BufReadPost' . (modifiable ? '' : '|setl nomodifiable')
|
||||
catch /^fugitive:/
|
||||
|
||||
Reference in New Issue
Block a user