diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 5e70b58..3e2a257 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1562,7 +1562,8 @@ function! fugitive#BufReadStatus() abort xnoremap g :execute StageDelete(line("'<"),line("'>")-line("'<")+1) nnoremap X :execute StageDelete(line('.'),v:count) xnoremap X :execute StageDelete(line("'<"),line("'>")-line("'<")+1) - nnoremap . : =fnameescape(get(StatusCfile(),0,'')) + nnoremap . : =StageArgs(0) + xnoremap . : =StageArgs(1) nnoremap :help fugitive-mappings set filetype=fugitive @@ -2165,6 +2166,21 @@ function! s:Selection(arg1, ...) abort return results endfunction +function! s:StageArgs(visual) abort + let commits = [] + let paths = [] + for record in s:Selection(a:visual ? 'v' : 'n') + if len(record.commit) + call add(commits, record.commit) + endif + call extend(paths, record.paths) + endfor + if s:cpath(s:Tree(), getcwd()) + call map(paths, 'fugitive#Path(v:val, "./")') + endif + return join(map(commits + paths, 's:fnameescape(v:val)'), ' ') +endfunction + function! s:Do(action, visual) abort let line = getline('.') if !a:0 && !v:count && line =~# '^[A-Z][a-z]' @@ -4225,7 +4241,8 @@ function! fugitive#MapJumps(...) abort nnoremap rs :Grebase --skip nnoremap re :Grebase --edit-todo nnoremap ra :Grebase --abort - nmap . : + nnoremap . : =fnameescape(fugitive#Real(@%)) + xnoremap . : =fnameescape(fugitive#Real(@%)) nnoremap g? :help fugitive-mappings endif endfunction