Skip to content

Commit df9452e

Browse files
suygithub-actions[bot]
authored andcommitted
fix(man.lua): show_toc condition may cause infinite loop #36979
`lnum` gets set with `vim.fn.nextnonblank`, which returns 0 on failure, and which is truthy on Lua. (cherry picked from commit 46220af)
1 parent 6f84ea7 commit df9452e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

runtime/lua/man.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ function M.show_toc()
795795

796796
local lnum = 2
797797
local last_line = fn.line('$') - 1
798-
while lnum and lnum < last_line do
798+
while lnum > 0 and lnum < last_line do
799799
local text = fn.getline(lnum)
800800
if text:match('^%s+[-+]%S') or text:match('^ %S') or text:match('^%S') then
801801
toc[#toc + 1] = {

0 commit comments

Comments
 (0)