vim-utils / vim-man

View and grep man pages in vim
247 stars 32 forks source link

Fix mappings causing infinite loop in some cases #29

Closed meribold closed 9 years ago

meribold commented 9 years ago

The <Plug> mappings in plugin/man.vim and some of the mappings specific to man page buffers (in fewer cases) can cause an infinite loop in the remove_blank_lines_from_top_and_bottom function.

This can happen when <cword> expands to the empty string inside man#get_page_from_cword or to anything else that will cause the function to call man#get_page with the empty string as the last argument. E.g.: use K inside a man page buffer while the cursor is on an empty line.

On my system, manpage_exists will return 1 because the output of man -w without extra arguments (/usr/local/man:/usr/local/share/man:/usr/share/man here) looks like a man page to it. man#helpers#load_manpage_text is then called with two empty strings and r!/usr/bin/man 2>/dev/null | col -b leaves the new buffer empty. Finally, remove_blank_lines_from_top_and_bottom goes into an infinite loop of trying to remove the only line in the buffer.

bruno- commented 9 years ago

This looks good. Thanks for contributing :+1: