Summary Folding should count fold start/stops at the current indentation level to properly pair a fold start with a fold end.
Details With my Lua bundle, I have folding set to work for block comments and functions (among other things).
If 'v' represents a start fold marker, and '^' represents and end fold marker, then creating an unindented (column 0) function looks like this:
v function foo( ) print( 'hey' ) ^ end
So far, so good. Now, suppose I block comment out this function (without indenting it):
v --[[ v function foo( ) print( 'hey' ) ^ end ^ ]]
This looks correct, but if I toggle the first folding marker, I get this:
> --[[••• ^ ]]
In other words, the folding looked for the first end marker that was at the same depth as the start marker, and (incorrectly) used the 'end' line. Instead, I propose that it should scan down and when it sees the second start fold marker at the same depth, add 1 to a counter; when it sees the first close fold marker at that depth, it checks the counter...since it is non-zero, it subtracts one. Finally, when it sees the last fold marker, and the counter is at zero, then it uses that as the correct, paired end fold.
P.S. What's the netiquette/guideline regarding attaching screenshot images inline to an email message to a mailing list, when that mailing list is almost certain to be used solely by MacOS users, who likely are using a Mail program that would support them? Would have been easier than the ascii art above (which itself is non-plain text, so I'm violating another common mailing list rule there).
On 12/10/2005, at 15.16, Gavin Kistner wrote:
I propose that it should scan down and when it sees the second start fold marker at the same depth, add 1 to a counter; when it sees the first close fold marker at that depth, it checks the counter...since it is non-zero, it subtracts one. Finally, when it sees the last fold marker, and the counter is at zero, then it uses that as the correct, paired end fold.
How about specifying folding markers in pairs? So it would only match the correct start to the correct end.
-- Sune.
On 12/10/2005, at 23.41, Sune Foldager wrote:
I propose that it should scan down and when it sees the second start fold marker at the same depth, add 1 to a counter; when it sees the first close fold marker at that depth, it checks the counter...since it is non-zero, it subtracts one. Finally, when it sees the last fold marker, and the counter is at zero, then it uses that as the correct, paired end fold.
It's conceptually done like that in latest build (I took a bit of freedom wrt the counter, since I already push/pop the markers on a stack ;) ).
How about specifying folding markers in pairs? So it would only match the correct start to the correct end.
Most languages only fold on { and }, or use a generic 'end' keyword to end different start blocks, so not much would be gained from this -- HTML comes to mind as one where there are different paired elements, but one could still have nested divs with same indent etc.
On 12/10/2005, at 15.16, Gavin Kistner wrote:
P.S. What's the netiquette/guideline regarding attaching screenshot images inline to an email message to a mailing list [...]
We've had lots of screen grabs in the past, and no complaints. So I think these are generally welcome.
The only thing I'm trying to uphold (without much success) is that people should NOT prefix their subjects with “feature request” or similar (and the subjects should generally be to the point [1]).
The way I deal with email is, I have letters open in separate windows, and if I need to reply to something (or take care of an issue), I leave that window open, until I have done so (sometimes for months :) ).
The Window menu is then my “outline” [2], and I'd love to not have to re-read a letter to figure out what it's about, or see 3-5 letters in a row with the same prefix, when they are actually from separate threads. For example currently the menu has this entry: “Re: [TXMT] Feature request/query — TM Users”.
I know that new people constantly join the list, and old people forget about my monthly reminders, but please try to keep this in mind!
And just to be clear, this was in no way directed at you Gavin, just found it time for my “monthly reminder” :)
[1] http://www.useit.com/alertbox/980906.html [2] Here's a tip, if you work like me: hold down option with the Window menu open, and Bring All to Front becomes Arrange in Front, which neatly stacks all open windows — works for most Cocoa applications.