mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-10 04:23:46 -05:00
Expand ~~ as cwd
This is a hedge to allow a way to force a cwd path even if the handling of "./" ever changes.
This commit is contained in:
@@ -1814,6 +1814,8 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort
|
|||||||
let buffer = s:BufName(len(a:other) > 1 ? '#'. a:other[1:-1] : '%')
|
let buffer = s:BufName(len(a:other) > 1 ? '#'. a:other[1:-1] : '%')
|
||||||
let owner = s:Owner(buffer)
|
let owner = s:Owner(buffer)
|
||||||
return len(owner) ? owner : '@'
|
return len(owner) ? owner : '@'
|
||||||
|
elseif a:other =~# '^\~[~.]$'
|
||||||
|
return s:Slash(getcwd())
|
||||||
elseif len(a:other)
|
elseif len(a:other)
|
||||||
return expand(a:other)
|
return expand(a:other)
|
||||||
elseif a:var ==# '<cfile>'
|
elseif a:var ==# '<cfile>'
|
||||||
@@ -1882,13 +1884,13 @@ function! s:Expand(rev, ...) abort
|
|||||||
let file = a:rev
|
let file = a:rev
|
||||||
endif
|
endif
|
||||||
return substitute(file,
|
return substitute(file,
|
||||||
\ '\(\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\)\|' . s:expand,
|
\ '\(\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\|^\~[~.]\)\|' . s:expand,
|
||||||
\ '\=tr(s:ExpandVar(submatch(1),submatch(2),submatch(3),"", a:0 ? a:1 : getcwd()), "\1", " ")', 'g')
|
\ '\=tr(s:ExpandVar(submatch(1),submatch(2),submatch(3),"", a:0 ? a:1 : getcwd()), "\1", " ")', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fugitive#Expand(object) abort
|
function! fugitive#Expand(object) abort
|
||||||
return substitute(a:object,
|
return substitute(a:object,
|
||||||
\ '\(\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\)\|' . s:expand,
|
\ '\(\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\|^\~[~.]\)\|' . s:expand,
|
||||||
\ '\=tr(s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5)), "\1", " ")', 'g')
|
\ '\=tr(s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5)), "\1", " ")', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -1909,7 +1911,7 @@ function! s:SplitExpandChain(string, ...) abort
|
|||||||
\ '\=s:DotRelative(s:Slash(simplify(getcwd() . "/" . submatch(0))), cwd)', '')
|
\ '\=s:DotRelative(s:Slash(simplify(getcwd() . "/" . submatch(0))), cwd)', '')
|
||||||
endif
|
endif
|
||||||
let arg = substitute(arg,
|
let arg = substitute(arg,
|
||||||
\ '\(' . dquote . '''\%(''''\|[^'']\)*''\|\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\|^\~\w*\|\$\w\+\)\|' . s:expand,
|
\ '\(' . dquote . '''\%(''''\|[^'']\)*''\|\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\|^\~[~]\|^\~\w*\|\$\w\+\)\|' . s:expand,
|
||||||
\ '\=s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5), cwd)', 'g')
|
\ '\=s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5), cwd)', 'g')
|
||||||
call extend(list, split(arg, "\1", 1))
|
call extend(list, split(arg, "\1", 1))
|
||||||
if arg ==# '--'
|
if arg ==# '--'
|
||||||
|
|||||||
Reference in New Issue
Block a user