[TxMt] How can TextMate be so popular???
Brad Choate
bchoate at gmail.com
Tue Mar 6 21:39:56 UTC 2007
What's throwing off the folding is the comment placed in the first
column. TextMate doesn't care about the presence or absence of that
comma when it looks for folds. It has patterns to match the start of
a fold and the end of a fold. It uses these patterns and indention
level to determine where fold points are and how to pair them. It
doesn't parse what is in-between.
If the user had pressed cmd+/ while on the "bar: function ( x ) {"
line, it would have added the comment characters after the leading
whitespace instead of the front of the line. Like this:
function foo () {
return {
// bar: function ( x ) {
bar: function ( x, y ) {
return x + y;
},
};
}
The function will fold properly when written that way, although TM
still sees the commented line as a fold point, something that should
probably be fixed.
-Brad
On Mar 6, 2007, at 1:30 PM, Michael Jackson wrote:
> Andy,
>
> It should be:
>
>> function foo () {
>> return {
>> // bar: function ( x ) {
>> bar: function ( x, y ) {
>> return x + y;
>> }
>> };
>> }
>
> NOT
>
>> function foo () {
>> return {
>> // bar: function ( x ) {
>> bar: function ( x, y ) {
>> return x + y;
>> }, <-- comma indicates that this key/value pair should be
>> followed by at least one more in this object
>> };
>> }
>
> Your browser may have parsed it, I dunno. I didn't try it. But with
> an editor that relies on regular expressions to match syntax,
> something as small as this would probably throw it off.
>
>
>
> Michael
>
>
>
> On Mar 6, 2007, at 2:24 PM, Andy Armstrong wrote:
>
>> On 6 Mar 2007, at 21:21, Michael Jackson wrote:
>>> Ha ha...now I KNOW you're an idiot. First, learn javascript. Your
>>> syntax is WRONG.
>>
>> Actually his syntax is just fine. What did you think was wrong
>> with it?
>>
>> [18:51] andy $ js
>> js>
>> js> function foo () {
>> return {
>> // bar: function ( x ) {
>> bar: function ( x, y ) {
>> return x + y;
>> },
>> };
>> }
>> js> x = foo()
>> [object Object]
>> js> x.bar(1, 2)
>> 3
>>
>>
>> --
>> Andy Armstrong, hexten.net
>>
>>
>> _____________________________________________________________________
>> _
>> For new threads USE THIS: textmate at lists.macromates.com
>> (threading gets destroyed and the universe will collapse if you
>> don't)
>> http://lists.macromates.com/mailman/listinfo/textmate
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
More information about the textmate
mailing list