diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index fb9bade..1c3a437 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1315,7 +1315,6 @@ function! s:Blame(bang,line1,line2,count,args) abort call s:throw('unsupported option') endif call map(a:args,'s:sub(v:val,"^\\ze[^-]","-")') - let git_dir = s:repo().dir() let cmd = ['--no-pager', 'blame', '--show-number'] + a:args if s:buffer().commit() =~# '\D\|..' let cmd += [s:buffer().commit()] @@ -1360,19 +1359,16 @@ function! s:Blame(bang,line1,line2,count,args) abort setlocal scrollbind nowrap nofoldenable let top = line('w0') + &scrolloff let current = line('.') + let s:temp_files[temp] = s:repo().dir() exe 'leftabove vsplit '.temp - let b:git_dir = git_dir - let b:fugitive_type = 'blame' let b:fugitive_blamed_bufnr = bufnr let w:fugitive_leave = restore let b:fugitive_blame_arguments = join(a:args,' ') - call s:Detect(expand('%:p')) execute top normal! zt execute current execute "vertical resize ".(match(getline('.'),'\s\+\d\+)')+1) - setlocal nomodified nomodifiable bufhidden=delete nonumber scrollbind nowrap foldcolumn=0 nofoldenable filetype=fugitiveblame - nnoremap q :bdelete + setlocal nomodified nomodifiable nonumber scrollbind nowrap foldcolumn=0 nofoldenable filetype=fugitiveblame nnoremap :exe BlameJump('') nnoremap P :exe BlameJump('^'.v:count1) nnoremap ~ :exe BlameJump('~'.v:count1) @@ -1878,6 +1874,23 @@ augroup fugitive_files autocmd FileType git call s:JumpInit() augroup END +" }}}1 +" Temp files {{{1 + +let s:temp_files = {} + +augroup fugitive_temp + autocmd! + autocmd BufNewFile,BufReadPost * + \ if has_key(s:temp_files,expand(':p')) | + \ let b:git_dir = s:temp_files[expand(':p')] | + \ let b:git_type = 'temp' | + \ call s:Detect(expand(':p')) | + \ setlocal bufhidden=delete | + \ nnoremap q :bdelete | + \ endif +augroup END + " }}}1 " Go to file {{{1