From 3d3b1641d0cae3244c09d4602ab96d290dd0928a Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 1 Feb 2017 15:12:52 -0500 Subject: 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. --- runtime/autoload/man.vim | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index a6be00c0a9..bd3aabf20c 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -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'. -- cgit