The folding start/end is greedy, it will allow folding to begin inside a comment. Should use ^ in the start/end perhaps. Example:
-- bisection method for solving non-linear equations
delta=1e-6 -- tolerance
function bisect(f,a,b,fa,fb) local c=(a+b)/2 io.write(n," c=",c," a=",a," b=",b,"\n") if c==a or c==b or math.abs(a-b)<delta then return c,b-a end n=n+1 local fc=f(c) if fa*fc<0 then return bisect(f,a,c,fa,fc) else return bisect (f,c,b,fc,fb) end end
(The for in the comment being the issue)