diff options
author | Joshua Rubin <joshuarubin@users.noreply.github.com> | 2019-10-25 10:41:22 -0600 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-10-25 09:41:22 -0700 |
commit | 99aa166cb105cb33df7bb153e93f15b509fcbc8c (patch) | |
tree | 0a1844941b95b8e1a39b2b18c47bbe92914c8345 /runtime | |
parent | 4f4f5ef4fd2f54db5d527768b4b1a94f737b3834 (diff) | |
download | rneovim-99aa166cb105cb33df7bb153e93f15b509fcbc8c.tar.gz rneovim-99aa166cb105cb33df7bb153e93f15b509fcbc8c.tar.bz2 rneovim-99aa166cb105cb33df7bb153e93f15b509fcbc8c.zip |
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>
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/man.vim | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 153f1afed8..a9256638e1 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -284,20 +284,16 @@ function! s:extract_sect_and_name_path(path) abort endfunction function! s:find_man() abort - if &filetype ==# 'man' - return 1 - elseif winnr('$') ==# 1 - return 0 - endif - let thiswin = winnr() - while 1 - wincmd w - if &filetype ==# 'man' + let l:win = 1 + while l:win <= winnr('$') + let l:buf = winbufnr(l:win) + if getbufvar(l:buf, '&filetype', '') ==# 'man' + execute l:win.'wincmd w' return 1 - elseif thiswin ==# winnr() - return 0 endif + let l:win += 1 endwhile + return 0 endfunction function! s:error(msg) abort |