Hi all,

I'm investigating an interesting meltdown of the folding system when opening CGI.pm from Perl 5.8.2 with the recent Perl package folding feature enabled.

Here is my current understanding of the failure:

Behaviour: When opening CGI.pm (this happens on opening only, I think), the editor tries to fold an inordinately large length of the file beyond the visible lines. The folding system goes through several levels of nesting and too many EnsureStyledTo() calls, leading to either the editor becoming unresponsive for a short time or an outright crash.

When package folding is enabled, everything after a file-level package statement is at level 1025 or above, while the package statement itself is at 1024.

The failure is triggered when the last line of a folding request is a fold header. SetLevel() triggers a notification, which ends up in FoldChanged(). FoldChanged calls Expand(), ending up in GetLastChild(). In GetLastChild(), an EnsureStyledTo() chain reaction occurs.

In GetLastChild(), for the while loop, the IsSubordinate() test always has 1024 as levelStart on the package statement line, and everything after that will be >= 1025, so levelStart < levelTry holds for the entire block and the while loop continues until the end of the package block, spewing lots of EnsureStyledTo() calls. There is also some nesting and redundant behaviour I don't fully understand.

I'm getting something like this:

lineMaxSubord:1964,maxLine:7125
EnsureStyledTo(1966)
IsSubordinate(400,401)
lineMaxSubord:1965,maxLine:7125
EnsureStyledTo(1967)
IsSubordinate(400,401)
lineMaxSubord:1966,maxLine:7125
EnsureStyledTo(1968)
IsSubordinate(400,401)
lineMaxSubord:1967,maxLine:7125
EnsureStyledTo(1969)
IsSubordinate(400,401)
...

Still studying the problem, not sure what to do yet. I can see that GetLastChild() does try to fold a whole child block, so maybe a package block is too large or complex for the current folding implementation to handle.

When the editor requests the whole file to be folded, there is no such problem as I suppose EnsureStyledTo() does not cause extra folding requests to be queued.

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia

_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to