mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 22:03:51 -05:00
Fix Gblame problems on Windows
On Windows, if Vim is invoked with a working directory starting with a lowercase drive letter (e.g. c:\<path> instead of C:\<path>), some mappings in the blame buffer do not work correctly. For example, hitting Enter on a line throws an exception rather than showing the associated commit. The reason for this is that the b:git_dir variable is not being set on the blame buffer. The reason in turn for this is that the path to the blame buffer is being stored in s:temp_files with an uppercase drive letter, but in the fugitive_temp augroup, '<afile>:p' is being expanded with a lowercase drive letter, so the lookup in s:temp_files fails. Fix this by converting paths to lowercase before using them as keys for the s:tempfile dictionary. Because of the way Vim generates temporary file names, this is safe even on platforms with case-sensitive file systems.
This commit is contained in:
@@ -1164,7 +1164,7 @@ function! s:Edit(cmd,bang,...) abort
|
|||||||
return 'redraw|echo '.string(':!'.git.' '.args)
|
return 'redraw|echo '.string(':!'.git.' '.args)
|
||||||
else
|
else
|
||||||
let temp = resolve(tempname())
|
let temp = resolve(tempname())
|
||||||
let s:temp_files[temp] = { 'dir': buffer.repo().dir(), 'args': arglist }
|
let s:temp_files[tolower(temp)] = { 'dir': buffer.repo().dir(), 'args': arglist }
|
||||||
silent execute a:cmd.' '.temp
|
silent execute a:cmd.' '.temp
|
||||||
if a:cmd =~# 'pedit'
|
if a:cmd =~# 'pedit'
|
||||||
wincmd P
|
wincmd P
|
||||||
@@ -1689,7 +1689,7 @@ function! s:Blame(bang,line1,line2,count,args) abort
|
|||||||
setlocal scrollbind nowrap nofoldenable
|
setlocal scrollbind nowrap nofoldenable
|
||||||
let top = line('w0') + &scrolloff
|
let top = line('w0') + &scrolloff
|
||||||
let current = line('.')
|
let current = line('.')
|
||||||
let s:temp_files[temp] = { 'dir': s:repo().dir(), 'args': cmd }
|
let s:temp_files[tolower(temp)] = { 'dir': s:repo().dir(), 'args': cmd }
|
||||||
exe 'keepalt leftabove vsplit '.temp
|
exe 'keepalt leftabove vsplit '.temp
|
||||||
let b:fugitive_blamed_bufnr = bufnr
|
let b:fugitive_blamed_bufnr = bufnr
|
||||||
let w:fugitive_leave = restore
|
let w:fugitive_leave = restore
|
||||||
@@ -2333,10 +2333,10 @@ endif
|
|||||||
augroup fugitive_temp
|
augroup fugitive_temp
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufNewFile,BufReadPost *
|
autocmd BufNewFile,BufReadPost *
|
||||||
\ if has_key(s:temp_files,expand('<afile>:p')) |
|
\ if has_key(s:temp_files,tolower(expand('<afile>:p'))) |
|
||||||
\ let b:git_dir = s:temp_files[expand('<afile>:p')].dir |
|
\ let b:git_dir = s:temp_files[tolower(expand('<afile>:p'))].dir |
|
||||||
\ let b:git_type = 'temp' |
|
\ let b:git_type = 'temp' |
|
||||||
\ let b:git_args = s:temp_files[expand('<afile>:p')].args |
|
\ let b:git_args = s:temp_files[tolower(expand('<afile>:p'))].args |
|
||||||
\ call fugitive#detect(expand('<afile>:p')) |
|
\ call fugitive#detect(expand('<afile>:p')) |
|
||||||
\ setlocal bufhidden=delete |
|
\ setlocal bufhidden=delete |
|
||||||
\ nnoremap <buffer> <silent> q :<C-U>bdelete<CR>|
|
\ nnoremap <buffer> <silent> q :<C-U>bdelete<CR>|
|
||||||
|
|||||||
Reference in New Issue
Block a user