Code: Select all
function ToggleFoldLv(x)
--~ if editor.Lexer == SCLEX_AU3 then
-- clear output pane when debugging
output:ClearAll()
fldonlev=tonumber(x)
--~ print("### Fold toggle fold level ", fldonlev)
local savlinlev1=-1
local fldinlev1=0
for a = 0, editor.LineCount-1, 1
do
if editor.FoldParent[a+1] < savlinlev1 then
--~ print("End of fold block",a+1)
savlinlev1=editor.FoldParent[a+1]
fldinlev1=fldinlev1-1
elseif editor.FoldParent[a+1] > savlinlev1 then
--~ print("Start of fold block")
savlinlev1=editor.FoldParent[a+1]
if fldonlev == fldinlev1 then
--~ print("! Toggle fold for line ", a+1)
editor:ToggleFold(a)
prefold=fldonlev
end
fldinlev1=fldinlev1+1
end
end
end
ToggleFoldLv(3)
There is a problem with this code
If the level is smaller than the specified level, all will be expanded.
What I hope is that if it is smaller than the specified level, it will also be folded.
Can anyone help modify this code?