From df9452ea9e646e300c3e1ed14408a00e1cb48dda Mon Sep 17 00:00:00 2001 From: Alejandro Exojo Date: Mon, 15 Dec 2025 17:02:10 +0100 Subject: [PATCH] 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 46220afef806e571b408973c51ba72acf009e078) --- runtime/lua/man.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index f0478dc113..3cbd1e9404 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -795,7 +795,7 @@ function M.show_toc() local lnum = 2 local last_line = fn.line('$') - 1 - while lnum and lnum < last_line do + while lnum > 0 and lnum < last_line do local text = fn.getline(lnum) if text:match('^%s+[-+]%S') or text:match('^ %S') or text:match('^%S') then toc[#toc + 1] = {