man.vim: more robust s:verify_exists #6043

Closes #6039

Also: close the window if we could not get the page from man but only if
we opened it ourselves.
This commit is contained in:
Anmol Sethi 2017-02-01 15:12:52 -05:00 committed by Justin M. Keyes
parent 6d4e08d226
commit 3d3b1641d0

View File

@ -55,7 +55,10 @@ function! man#open_page(count, count1, mods, ...) abort
try
let page = s:get_page(path)
catch
close
if a:mods =~# 'tab' || !s:find_man()
" a new window was opened
close
endif
call s:error(v:exception)
return
endtry
@ -175,13 +178,15 @@ function! s:get_path(sect, name) abort
endfunction
function! s:verify_exists(sect, name) abort
let path = s:get_path(a:sect, a:name)
if path !~# '^\/'
let path = s:get_path(get(b:, 'man_default_sects', ''), a:name)
if path !~# '^\/'
try
let path = s:get_path(a:sect, a:name)
catch /^command error (/
try
let path = s:get_path(get(b:, 'man_default_sects', ''), a:name)
catch /^command error (/
let path = s:get_path('', a:name)
endif
endif
endtry
endtry
" We need to extract the section from the path because sometimes
" the actual section of the manpage is more specific than the section
" we provided to `man`. Try ':Man 3 App::CLI'.