Sublime Forum

Add/implement child operator for sublime selectors

#1

According to docs/selectors.html
Sublime supports these operators for selectors:

  • () Grouping
  • - Logical NOT
  • & Logical AND
  • | Logical OR
  • , Logical OR

But I think one useful operator is missing: the “child operator” likewise in
CSS/Child_combinator

The reason why this operator is useful is almost the same as for HTML/CSS.

For example, when we want to match a comma inside a group ({a,b},c),
we can not simply write it as meta.group punctuation.separator, because it also includes the
comma inside the bracket {a,b}. If we have the “child operator”, we can simply use meta.group > punctuation.sepeartor;

This is useful for theme/coloring and view.match_selector().

1 Like

#2

Indeed, the current workarounds are not ideal. Probably worth logging at https://github.com/sublimehq/sublime_text/issues

1 Like

#3

Given all blocks and groups are scoped (e.g. meta.block and meta.group) a selector which just selects outer comma would look like:

meta.group punctuation.separator - meta.group meta

Task becomes interesting, if commas within nested groups are of interest only.

(a,b,{(c,d),(e,{(f,g),(h,i)})})

Selector above just matches outer commans after a and b.

Without detailed information or knowledge about possibly involved meta, it is not really possible to write such selector, currently.

A child selector solving this challange by just…

meta.group > punctuation.separator

would really be appriciated.

0 Likes

#4
1 Like