mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-09 12:03:47 -05:00
Don't append another filename when expanding ">commit:file"
This opens up the possibility of using ">" to navigate to a renamed version of a file, for example.
This commit is contained in:
@@ -1804,14 +1804,20 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Expand(rev, ...) abort
|
function! s:Expand(rev, ...) abort
|
||||||
if a:rev =~# '^:[0-3]$'
|
if a:rev =~# '^>\=:[0-3]$'
|
||||||
let file = len(expand('%')) ? a:rev . ':%' : '%'
|
let file = len(expand('%')) ? a:rev[-2:-1] . ':%' : '%'
|
||||||
elseif a:rev ==# '>'
|
elseif a:rev ==# '>'
|
||||||
let file = '%'
|
let file = '%'
|
||||||
elseif a:rev =~# '^>[~^]'
|
elseif a:rev ==# '>:'
|
||||||
let file = len(expand('%')) ? '!' . a:rev[1:-1] . ':%' : '%'
|
let file = empty(s:DirCommitFile(@%)[0]) ? ':0:%' : '%'
|
||||||
elseif a:rev =~# '^>[> ]\@!'
|
elseif a:rev =~# '^>[> ]\@!'
|
||||||
let file = len(expand('%')) ? a:rev[1:-1] . ':%' : '%'
|
let rev = (a:rev =~# '^>[~^]' ? '!' : '') . a:rev[1:-1]
|
||||||
|
let prefix = matchstr(rev, '^\%(\\.\|{[^{}]*}\|[^:]\)*')
|
||||||
|
if prefix !=# rev
|
||||||
|
let file = rev
|
||||||
|
else
|
||||||
|
let file = len(expand('%')) ? rev . ':%' : '%'
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
let file = a:rev
|
let file = a:rev
|
||||||
endif
|
endif
|
||||||
@@ -5676,7 +5682,7 @@ function! s:OpenParse(string, wants_cmd) abort
|
|||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
if len(args)
|
if len(args) && args !=# ['>:']
|
||||||
let file = join(args)
|
let file = join(args)
|
||||||
if file ==# '-'
|
if file ==# '-'
|
||||||
let result = fugitive#Result()
|
let result = fugitive#Result()
|
||||||
|
|||||||
Reference in New Issue
Block a user