mirror of
https://github.com/atom/atom.git
synced 2026-02-08 13:45:09 -05:00
Spans have a class for each dot-separated portion of their token's scope
Previously, we were rendering every prefix of the dot-separated scope as its own class. So the scope meta.delimiter.method.period.coffee would make a token w/ classes: class="meta, meta-delimiter, meta-delimiter-method, meta-delimiter-method-period…" Now we just give the token each piece of the scope as a class: class="meta delimiter method period coffee" We lose a bit of meaning, in that a scope selector method.period.coffee would match this element in CSS even though it *wouldn't* in TextMate. But we also gain the behavior where longer prefixes are more specific by naturally producing more specific css selectors. So '.meta.delimiter.method' is always more specific than '.meta.delimiter', whereas '.meta-delimiter-method' ties with '.meta-delimiter'. If prefix ambiguities become a problem later we may need to revisit this approach, but I think it's good enough for now.
This commit is contained in:
@@ -832,10 +832,7 @@ class Editor extends View
|
||||
|
||||
pushScope = (scope) ->
|
||||
scopeStack.push(scope)
|
||||
classes = []
|
||||
scopeComponents = scope.split('.')
|
||||
classes.push scopeComponents[0..i].join('-') for i in [0...scopeComponents.length]
|
||||
line.push("<span class=\"#{classes.join(' ')}\">")
|
||||
line.push("<span class=\"#{scope.replace(/\./g, ' ')}\">")
|
||||
|
||||
popScope = ->
|
||||
scopeStack.pop()
|
||||
|
||||
@@ -81,7 +81,7 @@ class TextMateTheme
|
||||
properties: @translateScopeSelectorSettings(settings)
|
||||
|
||||
translateScopeSelector: (textmateScopeSelector) ->
|
||||
scopes = textmateScopeSelector.replace(/\./g, '-').split(/\s+/).map (scope) -> '.' + scope
|
||||
scopes = textmateScopeSelector.split(/\s+/).map (scope) -> '.' + scope
|
||||
scopes.join(' ')
|
||||
|
||||
translateScopeSelectorSettings: ({ foreground, background, fontStyle }) ->
|
||||
|
||||
Reference in New Issue
Block a user