mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
man.vim: never switch to non-man window #11286
In order to find if there was already an open man page, the :Man command would cycle through each window to see if &ft=='man'. This triggers autocmds, e.g. BufEnter, unnecessarily and can have unexpected side-effects. Change the logic to check each window's ft without switching to it unless it is actually a man window. Signed-off-by: Joshua Rubin <me@jawa.dev>
This commit is contained in:

committed by
Justin M. Keyes

parent
4f4f5ef4fd
commit
99aa166cb1
@@ -284,20 +284,16 @@ function! s:extract_sect_and_name_path(path) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:find_man() abort
|
function! s:find_man() abort
|
||||||
if &filetype ==# 'man'
|
let l:win = 1
|
||||||
return 1
|
while l:win <= winnr('$')
|
||||||
elseif winnr('$') ==# 1
|
let l:buf = winbufnr(l:win)
|
||||||
return 0
|
if getbufvar(l:buf, '&filetype', '') ==# 'man'
|
||||||
endif
|
execute l:win.'wincmd w'
|
||||||
let thiswin = winnr()
|
|
||||||
while 1
|
|
||||||
wincmd w
|
|
||||||
if &filetype ==# 'man'
|
|
||||||
return 1
|
return 1
|
||||||
elseif thiswin ==# winnr()
|
|
||||||
return 0
|
|
||||||
endif
|
endif
|
||||||
|
let l:win += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:error(msg) abort
|
function! s:error(msg) abort
|
||||||
|
Reference in New Issue
Block a user