mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-15 14:53:51 -05:00
Prevent bad modeline from blocking a :split
Closes https://github.com/tpope/vim-fugitive/issues/1136
This commit is contained in:
@@ -1345,7 +1345,6 @@ function! s:ReplaceCmd(cmd, ...) abort
|
|||||||
endif
|
endif
|
||||||
let temp = s:Resolve(temp)
|
let temp = s:Resolve(temp)
|
||||||
let fn = expand('%:p')
|
let fn = expand('%:p')
|
||||||
silent exe 'doau BufReadPre '.s:fnameescape(fn)
|
|
||||||
silent exe 'keepalt file '.temp
|
silent exe 'keepalt file '.temp
|
||||||
let modelines = &modelines
|
let modelines = &modelines
|
||||||
try
|
try
|
||||||
@@ -1365,7 +1364,6 @@ function! s:ReplaceCmd(cmd, ...) abort
|
|||||||
if s:cpath(fnamemodify(bufname('$'), ':p'), temp)
|
if s:cpath(fnamemodify(bufname('$'), ':p'), temp)
|
||||||
silent execute 'bwipeout '.bufnr('$')
|
silent execute 'bwipeout '.bufnr('$')
|
||||||
endif
|
endif
|
||||||
silent exe 'doau BufReadPost '.s:fnameescape(fn)
|
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -1377,6 +1375,7 @@ function! fugitive#BufReadStatus() abort
|
|||||||
let b:fugitive_display_format = b:fugitive_display_format % 2
|
let b:fugitive_display_format = b:fugitive_display_format % 2
|
||||||
let b:fugitive_type = 'index'
|
let b:fugitive_type = 'index'
|
||||||
try
|
try
|
||||||
|
silent doautocmd BufReadPre
|
||||||
let cmd = [fnamemodify(amatch, ':h')]
|
let cmd = [fnamemodify(amatch, ':h')]
|
||||||
setlocal noro ma nomodeline
|
setlocal noro ma nomodeline
|
||||||
if s:cpath(fnamemodify($GIT_INDEX_FILE !=# '' ? $GIT_INDEX_FILE : b:git_dir . '/index', ':p')) !=# s:cpath(amatch)
|
if s:cpath(fnamemodify($GIT_INDEX_FILE !=# '' ? $GIT_INDEX_FILE : b:git_dir . '/index', ':p')) !=# s:cpath(amatch)
|
||||||
@@ -1446,6 +1445,7 @@ function! fugitive#BufReadStatus() abort
|
|||||||
nnoremap <buffer> . : <C-R>=<SID>fnameescape(<SID>StatusCfile())<CR><Home>
|
nnoremap <buffer> . : <C-R>=<SID>fnameescape(<SID>StatusCfile())<CR><Home>
|
||||||
nnoremap <buffer> <silent> g? :help fugitive-:Gstatus<CR>
|
nnoremap <buffer> <silent> g? :help fugitive-:Gstatus<CR>
|
||||||
nnoremap <buffer> <silent> <F1> :help fugitive-:Gstatus<CR>
|
nnoremap <buffer> <silent> <F1> :help fugitive-:Gstatus<CR>
|
||||||
|
return 'silent doautocmd BufReadPost'
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr v:errmsg'
|
return 'echoerr v:errmsg'
|
||||||
endtry
|
endtry
|
||||||
@@ -1521,7 +1521,7 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
unlet b:fugitive_type
|
unlet b:fugitive_type
|
||||||
if rev =~# '^:\d:'
|
if rev =~# '^:\d:'
|
||||||
let &readonly = !filewritable(dir . '/index')
|
let &readonly = !filewritable(dir . '/index')
|
||||||
return 'silent doautocmd BufNewFile '.s:fnameescape(amatch)
|
return 'silent doautocmd BufNewFile'
|
||||||
else
|
else
|
||||||
setlocal readonly nomodifiable
|
setlocal readonly nomodifiable
|
||||||
return 'echo ' . string(error)
|
return 'echo ' . string(error)
|
||||||
@@ -1544,6 +1544,7 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
setlocal endofline
|
setlocal endofline
|
||||||
|
|
||||||
try
|
try
|
||||||
|
silent doautocmd BufReadPre
|
||||||
if b:fugitive_type ==# 'tree'
|
if b:fugitive_type ==# 'tree'
|
||||||
let b:fugitive_display_format = b:fugitive_display_format % 2
|
let b:fugitive_display_format = b:fugitive_display_format % 2
|
||||||
if b:fugitive_display_format
|
if b:fugitive_display_format
|
||||||
@@ -1584,17 +1585,12 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
call s:ReplaceCmd([dir, 'ls-files', '--stage'])
|
call s:ReplaceCmd([dir, 'ls-files', '--stage'])
|
||||||
elseif b:fugitive_type ==# 'blob'
|
elseif b:fugitive_type ==# 'blob'
|
||||||
call s:ReplaceCmd([dir, 'cat-file', b:fugitive_type, rev])
|
call s:ReplaceCmd([dir, 'cat-file', b:fugitive_type, rev])
|
||||||
setlocal nomodeline
|
|
||||||
endif
|
endif
|
||||||
finally
|
finally
|
||||||
keepjumps call setpos('.',pos)
|
keepjumps call setpos('.',pos)
|
||||||
setlocal nomodified noswapfile
|
setlocal nomodified noswapfile
|
||||||
if rev !~# '^:.:'
|
let modifiable = rev =~# '^:.:' && b:fugitive_type !=# 'tree'
|
||||||
setlocal nomodifiable
|
let &readonly = !modifiable || !filewritable(dir . '/index')
|
||||||
else
|
|
||||||
let &modifiable = b:fugitive_type !=# 'tree'
|
|
||||||
endif
|
|
||||||
let &readonly = !&modifiable || !filewritable(dir . '/index')
|
|
||||||
if &bufhidden ==# ''
|
if &bufhidden ==# ''
|
||||||
setlocal bufhidden=delete
|
setlocal bufhidden=delete
|
||||||
endif
|
endif
|
||||||
@@ -1607,7 +1603,8 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
endif
|
endif
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
return ''
|
return 'silent doautocmd' . (v:version >= 704 ? ' <nomodeline>' : '') .
|
||||||
|
\ ' BufReadPost' . (modifiable ? '' : '|setl nomodifiable')
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr v:errmsg'
|
return 'echoerr v:errmsg'
|
||||||
endtry
|
endtry
|
||||||
|
|||||||
Reference in New Issue
Block a user