Packages: [CSS] Symbol Index includes Leading Whitespace

Created on 21 Aug 2019  路  3Comments  路  Source: sublimehq/Packages

The selector for Goto Symbol in a CSS file is meta.selector, which appears to be matching leading whitespace before the start of a selector.

Test case:

        body {
            font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial;
            background-color: #f6f6f6;
            text-align: center;
        }
        h1 {
            margin-top: 100px;
            font-size: 4.0em;
            color: #333;
        }

Most helpful comment

Maybe a general question about what to include into meta scopes and into the index in the end. The meta.selector may in general be meant to return the whole region, we expect selectors (including leading and trailing ws) in or it might be limited to the real selector string (excluding leading and trailing ws).

While indexing the whole meta.selector to group the single entities may by the best compromise atm, a general solution to only index the h1, h2 separately would make more sense.

All 3 comments

FWIW, I _think_ the reason it does that is to make sure that ,-separated selectors are grouped together into the same meta scope. A fix should either maintain that or make an argument why it shouldn't be that way.

Test cases:

        h1, h2 {
            margin-top: 100px;
            font-size: 4.0em;
            color: #333;
        }
        h1 , h2 {
            margin-top: 100px;
            font-size: 4.0em;
            color: #333;
        }
        h1,
        h2 {
            margin-top: 100px;
            font-size: 4.0em;
            color: #333;
        }

Whitespace between parts of a selector sounds fine, it is the leading whitespace that is an issue.

Currently there are two issues:

  1. When you jump to a symbol, it selects a bunch of leading whitespace
  2. If you are using symbol information for something else, you have to know that some symbols will need to have whitespace trimmed from the beginning

Maybe a general question about what to include into meta scopes and into the index in the end. The meta.selector may in general be meant to return the whole region, we expect selectors (including leading and trailing ws) in or it might be limited to the real selector string (excluding leading and trailing ws).

While indexing the whole meta.selector to group the single entities may by the best compromise atm, a general solution to only index the h1, h2 separately would make more sense.

Was this page helpful?
0 / 5 - 0 ratings