mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-09 20:13:46 -05:00
Fix Fugitive activation when historical version does not exist
I believe I omitted BufNewFile here because it seemed like kind of a silly event for an unmodifiable, unwritable buffer, but I wasn't taking into account that event is needed for Fugitive to activate. Closes https://github.com/tpope/vim-fugitive/issues/1261
This commit is contained in:
@@ -1688,12 +1688,16 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
if v:shell_error
|
if v:shell_error
|
||||||
let error = b:fugitive_type
|
let error = b:fugitive_type
|
||||||
unlet b:fugitive_type
|
unlet b:fugitive_type
|
||||||
|
setlocal noswapfile
|
||||||
|
if empty(&bufhidden)
|
||||||
|
setlocal bufhidden=delete
|
||||||
|
endif
|
||||||
if rev =~# '^:\d:'
|
if rev =~# '^:\d:'
|
||||||
let &l:readonly = !filewritable(fugitive#Find('.git/index', dir))
|
let &l:readonly = !filewritable(fugitive#Find('.git/index', dir))
|
||||||
return 'silent doautocmd BufNewFile'
|
return 'silent doautocmd BufNewFile'
|
||||||
else
|
else
|
||||||
setlocal readonly nomodifiable
|
setlocal readonly nomodifiable
|
||||||
return 'echo ' . string(error)
|
return 'silent doautocmd BufNewFile|echo ' . string(error)
|
||||||
endif
|
endif
|
||||||
elseif b:fugitive_type !~# '^\%(tag\|commit\|tree\|blob\)$'
|
elseif b:fugitive_type !~# '^\%(tag\|commit\|tree\|blob\)$'
|
||||||
return "echoerr ".string("fugitive: unrecognized git type '".b:fugitive_type."'")
|
return "echoerr ".string("fugitive: unrecognized git type '".b:fugitive_type."'")
|
||||||
@@ -1760,7 +1764,7 @@ function! fugitive#BufReadCmd(...) abort
|
|||||||
setlocal nomodified noswapfile
|
setlocal nomodified noswapfile
|
||||||
let modifiable = rev =~# '^:.:' && b:fugitive_type !=# 'tree'
|
let modifiable = rev =~# '^:.:' && b:fugitive_type !=# 'tree'
|
||||||
let &l:readonly = !modifiable || !filewritable(fugitive#Find('.git/index', dir))
|
let &l:readonly = !modifiable || !filewritable(fugitive#Find('.git/index', dir))
|
||||||
if &bufhidden ==# ''
|
if empty(&bufhidden)
|
||||||
setlocal bufhidden=delete
|
setlocal bufhidden=delete
|
||||||
endif
|
endif
|
||||||
let &l:modifiable = modifiable
|
let &l:modifiable = modifiable
|
||||||
|
|||||||
Reference in New Issue
Block a user