commit 3d30a2a6d371dc97848d656c927d95e601bc473a (tree)
parent 254cc8e81d67739dc6b87dd9c3069485246a7b51
Author: Tim Pope <code@tpope.net>
Date: Wed, 1 Sep 2021 08:34:00 -0400
Expand ~~ as cwd
This is a hedge to allow a way to force a cwd path even if the
handling of "./" ever changes.
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -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 owner = s:Owner(buffer)
return len(owner) ? owner : '@'
+ elseif a:other =~# '^\~[~.]$'
+ return s:Slash(getcwd())
elseif len(a:other)
return expand(a:other)
elseif a:var ==# '<cfile>'
@@ -1882,13 +1884,13 @@ function! s:Expand(rev, ...) abort
let file = a:rev
endif
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')
endfunction
function! fugitive#Expand(object) abort
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')
endfunction
@@ -1909,7 +1911,7 @@ function! s:SplitExpandChain(string, ...) abort
\ '\=s:DotRelative(s:Slash(simplify(getcwd() . "/" . submatch(0))), cwd)', '')
endif
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')
call extend(list, split(arg, "\1", 1))
if arg ==# '--'