From 41a734ef49c78cfdb97426cda811ee99c39e011a Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 3 Jun 2019 21:06:59 -0400 Subject: [PATCH] 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 --- autoload/fugitive.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 898eba5..126ccf3 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1688,12 +1688,16 @@ function! fugitive#BufReadCmd(...) abort if v:shell_error let error = b:fugitive_type unlet b:fugitive_type + setlocal noswapfile + if empty(&bufhidden) + setlocal bufhidden=delete + endif if rev =~# '^:\d:' let &l:readonly = !filewritable(fugitive#Find('.git/index', dir)) return 'silent doautocmd BufNewFile' else setlocal readonly nomodifiable - return 'echo ' . string(error) + return 'silent doautocmd BufNewFile|echo ' . string(error) endif elseif b:fugitive_type !~# '^\%(tag\|commit\|tree\|blob\)$' return "echoerr ".string("fugitive: unrecognized git type '".b:fugitive_type."'") @@ -1760,7 +1764,7 @@ function! fugitive#BufReadCmd(...) abort setlocal nomodified noswapfile let modifiable = rev =~# '^:.:' && b:fugitive_type !=# 'tree' let &l:readonly = !modifiable || !filewritable(fugitive#Find('.git/index', dir)) - if &bufhidden ==# '' + if empty(&bufhidden) setlocal bufhidden=delete endif let &l:modifiable = modifiable