Fix :Gbrowse when argument starts with a digit

This commit is contained in:
Tim Pope
2012-10-16 00:18:41 -04:00
parent f43393dd9a
commit 05763df0ed

View File

@@ -1767,7 +1767,7 @@ endfunction
" }}}1 " }}}1
" Gbrowse {{{1 " Gbrowse {{{1
call s:command("-bar -bang -count=0 -nargs=? -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)") call s:command("-bar -bang -range -nargs=? -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(<bang>0,<line1>,<count>,<f-args>)")
function! s:Browse(bang,line1,count,...) abort function! s:Browse(bang,line1,count,...) abort
try try
@@ -1849,7 +1849,7 @@ function! s:Browse(bang,line1,count,...) abort
let url = s:github_url(s:repo(),raw,rev,commit,path,type,a:line1,a:count) let url = s:github_url(s:repo(),raw,rev,commit,path,type,a:line1,a:count)
if url == '' if url == ''
let url = s:instaweb_url(s:repo(),rev,commit,path,type,a:count ? a:line1 : 0) let url = s:instaweb_url(s:repo(),rev,commit,path,type,a:count > 0 ? a:line1 : 0)
endif endif
if url == '' if url == ''
@@ -1907,9 +1907,9 @@ function! s:github_url(repo,url,rev,commit,path,type,line1,line2) abort
let url = s:sub(root . '/tree/' . commit . '/' . path,'/$','') let url = s:sub(root . '/tree/' . commit . '/' . path,'/$','')
elseif a:type == 'blob' elseif a:type == 'blob'
let url = root . '/blob/' . commit . '/' . path let url = root . '/blob/' . commit . '/' . path
if a:line2 && a:line1 == a:line2 if a:line2 > 0 && a:line1 == a:line2
let url .= '#L' . a:line1 let url .= '#L' . a:line1
elseif a:line2 elseif a:line2 > 0
let url .= '#L' . a:line1 . '-' . a:line2 let url .= '#L' . a:line1 . '-' . a:line2
endif endif
elseif a:type == 'tag' elseif a:type == 'tag'