Provide slightly less bad "." map in temp buffers

Doing this right isn't on the horizon, so hack up something that's
better than nothing.
This commit is contained in:
Tim Pope
2021-08-27 11:12:45 -04:00
parent fa5892dcac
commit 18fd27e2cc

View File

@@ -2946,6 +2946,22 @@ function! fugitive#Result(...) abort
endif endif
endfunction endfunction
function! s:TempDotMap() abort
let cfile = s:cfile()
if empty(cfile)
return expand('<cword>')
endif
let name = fugitive#Find(cfile[0])
let [dir, commit, file] = s:DirCommitFile(name)
if len(commit) && empty(file)
return commit
elseif s:cpath(s:Tree(), getcwd())
return fugitive#Path(name, "./")
else
return fugitive#Real(name)
endif
endfunction
function! s:TempReadPre(file) abort function! s:TempReadPre(file) abort
if has_key(s:temp_files, s:cpath(a:file)) if has_key(s:temp_files, s:cpath(a:file))
let dict = s:temp_files[s:cpath(a:file)] let dict = s:temp_files[s:cpath(a:file)]
@@ -2970,6 +2986,8 @@ function! s:TempReadPost(file) abort
endif endif
if get(dict, 'filetype', '') ==# 'git' if get(dict, 'filetype', '') ==# 'git'
call fugitive#MapJumps() call fugitive#MapJumps()
call s:Map('n', '.', ":<C-U> <C-R>=<SID>fnameescape(<SID>TempDotMap())<CR><Home>")
call s:Map('x', '.', ":<C-U> <C-R>=<SID>fnameescape(<SID>TempDotMap())<CR><Home>")
endif endif
if has_key(dict, 'filetype') if has_key(dict, 'filetype')
if dict.filetype ==# 'man' && has('nvim') if dict.filetype ==# 'man' && has('nvim')