From e9f93be3562b6379472ca7d16c12ac082419b9f7 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 12 Jul 2021 15:27:33 -0400 Subject: [PATCH] Generalize :GBrowse - to all temp buffers --- autoload/fugitive.vim | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 84ddd4d..9ec7451 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -6240,15 +6240,9 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo let rev = '' let result = fugitive#Result() if filereadable(get(result, 'file', '')) - for line in readfile(result.file, 4096) - let rev = s:fnameescape(matchstr(line, '\]*[^[:space:]<>.,;:"''!?]')) - if len(rev) - break - endif - endfor - if empty(rev) - return 'echoerr ' . string('fugitive: no URL found in output of last :Git') - endif + let rev = s:fnameescape(result.file) + else + return 'echoerr ' . string('fugitive: could not find prior :Git invocation') endif elseif !exists('l:remote') 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:' return s:BrowserOpen(s:Slash(expanded), a:mods, a:bang) 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, '\]*[^[: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) if empty(expanded) let bufname = s:BufName('%')