From d4d2b9c6b237d2cba256e33c0755a46be2071447 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 6 Apr 2021 21:48:36 -0400 Subject: [PATCH] Ignore :GBrowse line numbers for non-blob objects Pave the way to use these for other purposes. --- autoload/fugitive.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0a0a160..d55cfdd 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -6208,8 +6208,8 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo endif endif - let line1 = a:count > 0 ? a:line1 : 0 - let line2 = a:count > 0 ? a:count : 0 + let line1 = a:count > 0 && type ==# 'blob' ? a:line1 : 0 + let line2 = a:count > 0 && type ==# 'blob' ? a:count : 0 if empty(commit) && path !~# '^\.git/' if a:count < 0 && !empty(merge) let commit = merge @@ -6221,12 +6221,12 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo if exec_error let commit = '' endif - if a:count > 0 && empty(arg) && commit =~# '^\x\{40,\}$' + if line2 > 0 && empty(arg) && commit =~# '^\x\{40,\}$' let blame_list = tempname() call writefile([commit, ''], blame_list, 'b') let blame_in = tempname() silent exe '%write' blame_in - let [blame, exec_error] = s:LinesError(['-c', 'blame.coloring=none', 'blame', '--contents', blame_in, '-L', a:line1.','.a:count, '-S', blame_list, '-s', '--show-number', './' . path]) + let [blame, exec_error] = s:LinesError(['-c', 'blame.coloring=none', 'blame', '--contents', blame_in, '-L', line1.','.line2, '-S', blame_list, '-s', '--show-number', './' . path]) if !exec_error let blame_regex = '^\^\x\+\s\+\zs\d\+\ze\s' if get(blame, 0) =~# blame_regex && get(blame, -1) =~# blame_regex