From 9bd7c264662e7ed5e58b29898508b290f0b260eb Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 29 Mar 2021 23:09:54 -0400 Subject: [PATCH] Expand This doesn't play well with :Git as it can result in a fugitive:// URL, but it does make :Gedit and :GBrowse do what I mean. --- autoload/fugitive.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 216b5a2..8a8949a 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1159,7 +1159,7 @@ function! fugitive#Object(...) abort endif endfunction -let s:var = '\%(%\|#<\=\d\+\|##\=\)' +let s:var = '\%(%\|#<\=\d\+\|##\=\|\)' let s:flag = '\%(:[p8~.htre]\|:g\=s\(.\).\{-\}\1.\{-\}\1\)' let s:expand = '\%(\(' . s:var . '\)\(' . s:flag . '*\)\(:S\)\=\)' @@ -1194,6 +1194,15 @@ 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:var ==# '' + let cfile = expand('') + if v:version >= 704 && get(maparg('', 'c', 0, 1), 'expr') + try + let cfile = eval(maparg('', 'c')) + catch + endtry + endif + return cfile endif let flags = a:flags let file = s:DotRelative(fugitive#Real(s:BufName(a:var)), cwd)