Home Download Buy Blog Forum Support

Scope selectors ranking matches - possible bug

Scope selectors ranking matches - possible bug

Postby Jarry Dark on Mon Oct 12, 2009 9:25 pm

In this scope at id attribute in HTML tag:

entity.other.attribute-name.id.html meta-attribute-with-value.id.html meta.tag.block.any.html text.html.basic

scope selector (1): meta.tag entity
wins over scope selector (2): entity.other.attribute-name.id.html

I would argue that by this definition: http://manual.macromates.com/en/scope_selectors
scope selector (2) should win in step 2, first pass.

I can't try this in TextMate, but this is how e does it.
Jarry Dark
 
Posts: 8
Joined: Thu Oct 08, 2009 12:45 pm

Re: Scope selectors ranking matches - possible bug

Postby Jarry Dark on Tue Oct 13, 2009 5:44 am

Yes, I noticed this with theming.

It seems that here, as you described it, level (or depth) of two selectors is equal (second part of (1) and (2)), but first wins because it is descendant selector, although the second one has higher specificity. Descendant selectors resolution in step 3 should get in the picture only when there is a tie, but there is no tie here.
Jarry Dark
 
Posts: 8
Joined: Thu Oct 08, 2009 12:45 pm

Re: Scope selectors ranking matches - possible bug

Postby Jarry Dark on Tue Oct 13, 2009 5:50 am

To illustrate, in scope a.b c.d.e.f selector a.b c should lose against

c.d.e.f
c.d.e
c.d

but it should win over c, because of descendancy.
Jarry Dark
 
Posts: 8
Joined: Thu Oct 08, 2009 12:45 pm

Re: Scope selectors ranking matches - possible bug

Postby Jarry Dark on Tue Oct 13, 2009 5:56 am

Also, step 3 should be clever about cases like this one:

scope: a.b c.d e.f g.h

and selectors:
a.b c.d e g.h
a.b e.f g.h
Jarry Dark
 
Posts: 8
Joined: Thu Oct 08, 2009 12:45 pm

Re: Scope selectors ranking matches - possible bug

Postby jps on Tue Oct 13, 2009 11:25 am

This is indeed a bug, I've put it on the list of things to fix.

Internally, since selectors form a regular language, sublime transforms them into regexes. To rank selectors vs. a scope, it simply takes the selector with the leftmost longest match. This is an approximation of the TextMate ranking scheme, but it doesn't always rank in the same way - I'll need to change the ranking to be done in a per-scope element iterative method.
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Next

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 27 guests