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

Color Scheme rules applied differently to Sublime #133

Closed
keith-hall opened this issue Jan 11, 2018 · 0 comments · Fixed by #209
Closed

Color Scheme rules applied differently to Sublime #133

keith-hall opened this issue Jan 11, 2018 · 0 comments · Fixed by #209
Labels

Comments

@keith-hall
Copy link
Collaborator

In Sublime Text, given a simple color scheme like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Test</string>
    <key>settings</key>
    <array>
        <dict>
            <key>settings</key>
            <dict>
                <key>background</key>
                <string>#2b303b</string>
                <key>foreground</key>
                <string>#c0c5ce</string>
            </dict>
        </dict>
        <dict>
            <key>scope</key>
            <string>comment</string>
            <key>settings</key>
            <dict>
                <key>background</key>
                <string>#FD971F</string>
                <key>foreground</key>
                <string>#AAAAAA</string>
            </dict>
        </dict>
        <dict>
            <key>scope</key>
            <string>comment.line</string>
            <key>settings</key>
            <dict>
                <key>foreground</key>
                <string>#FFFCFF</string>
            </dict>
        </dict>
    </array>
</dict>
</plist>

and some sample Python text like # test, the background rule from the comment scope selector applies, and the foreground rule from the comment.line scope selector applies, as can be seen by:

>>> view.style_for_scope('comment.line')
{'source_column': -1, 'source_file': 'Packages/User/test.tmTheme', 'background': '#fd971f', 'foreground': '#fffcff', 'italic': False, 'source_line': -1, 'bold': False}

This is because Sublime applies rules from all scope selectors in the color scheme that match the scope stack, in ascending order of their score, so that the rules with a higher score override those with a lower score.
In syntect, currently it just uses the rule with the highest matching score, and so the background from comment isn't applied.

<pre style="background-color:#2b303b;">
<span style="color:#fffcff;"># test</span><!-- missing `background-color:#fd971f` -->
</pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant