Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add child combinator ">" (and fix a specificity bug) #233

Merged
merged 7 commits into from
Jul 6, 2024

Commits on Jun 7, 2024

  1. feat: fix 2 bugs and add child combinator ">"

    Bug: Just because a trie element exists for a more specific scope doesn‘t mean its parent scopes will match, so we need to collect the trie elements with less specific scopes too.
    
    Bug: If the number of scope names in both rules‘ scope paths are not
    equal, the parent scope names won‘t be compared at all. Instead, the rule with
    the longest scope path is preferred. This goes against the TextMate
    manual (https://macromates.com/manual/en/scope_selectors). In
    particular, the following line in “Ranking Matches”:
    > Rules 1 and 2 applied again to the scope selector when removing the deepest element (in the case of a tie)
    
    Feature: Add support for the child combinator (the `>` operator). This
    allows for styling a parent-child relationship specifically.
    aleclarson committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    62d814f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4a647ed View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6413f59 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    04dd80f View commit details
    Browse the repository at this point in the history
  5. test: add 3 new cases

    - One for the new child combinator
    - One for bug 1 ("Theme resolving falls back to less specific rules")
    - One for bug 2 ("Theme resolving should give deeper scopes higher specificity")
    aleclarson committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    9a03df2 View commit details
    Browse the repository at this point in the history
  6. chore(revert): undo bug 1 fix

    After trying to reproduce the alleged bug, I realized it‘s not a bug. When a ThemeTrieElement is created, it inherits the `_rulesWithParentScopes` array of its parent element, which is guaranteed to be populated due to the lexicographical sorting of the theme rules in `resolveParsedThemeRules`.
    aleclarson committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    34a8157 View commit details
    Browse the repository at this point in the history
  7. test: remove test case for non-existent bug

    …and update the other bug‘s test case to actually fail on the main branch
    aleclarson committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    7c14889 View commit details
    Browse the repository at this point in the history