Generalize :GBrowse - to all temp buffers

This commit is contained in:
Tim Pope
2021-07-12 15:27:33 -04:00
parent fd5b553029
commit e9f93be356

View File

@@ -6240,15 +6240,9 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo
let rev = '' let rev = ''
let result = fugitive#Result() let result = fugitive#Result()
if filereadable(get(result, 'file', '')) if filereadable(get(result, 'file', ''))
for line in readfile(result.file, 4096) let rev = s:fnameescape(result.file)
let rev = s:fnameescape(matchstr(line, '\<https\=://[^[:space:]<>]*[^[:space:]<>.,;:"''!?]')) else
if len(rev) return 'echoerr ' . string('fugitive: could not find prior :Git invocation')
break
endif
endfor
if empty(rev)
return 'echoerr ' . string('fugitive: no URL found in output of last :Git')
endif
endif endif
elseif !exists('l:remote') elseif !exists('l:remote')
let remote = matchstr(arg, '@\zs\%('.validremote.'\)$') let remote = matchstr(arg, '@\zs\%('.validremote.'\)$')
@@ -6265,6 +6259,20 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo
if expanded =~? '^\a\a\+:[\/][\/]' && expanded !~? '^fugitive:' if expanded =~? '^\a\a\+:[\/][\/]' && expanded !~? '^fugitive:'
return s:BrowserOpen(s:Slash(expanded), a:mods, a:bang) return s:BrowserOpen(s:Slash(expanded), a:mods, a:bang)
endif endif
if !exists('l:result')
let result = s:TempState(empty(expanded) ? @% : expanded)
endif
if !empty(result) && filereadable(get(result, 'file', ''))
for line in readfile(result.file, 4096)
let rev = s:fnameescape(matchstr(line, '\<https\=://[^[:space:]<>]*[^[:space:]<>.,;:"''!?]'))
if len(rev)
break
endif
endfor
if empty(rev)
return 'echoerr ' . string('fugitive: no URL found in output of :Git')
endif
endif
exe s:DirCheck(dir) exe s:DirCheck(dir)
if empty(expanded) if empty(expanded)
let bufname = s:BufName('%') let bufname = s:BufName('%')