Fix one edge case with comma scopes
This commit is contained in:
@@ -116,8 +116,9 @@ class Theme(NamedTuple):
|
||||
scopes = ['']
|
||||
elif isinstance(rule['scope'], str):
|
||||
scopes = [
|
||||
# some themes have a buggy trailing comma
|
||||
s.strip() for s in rule['scope'].strip(',').split(',')
|
||||
s.strip()
|
||||
# some themes have a buggy trailing/leading comma
|
||||
for s in rule['scope'].strip().strip(',').split(',')
|
||||
]
|
||||
else:
|
||||
scopes = rule['scope']
|
||||
|
||||
@@ -72,6 +72,18 @@ def test_theme_scope_split_by_commas():
|
||||
assert theme.select(('c',)).i is True
|
||||
|
||||
|
||||
def test_theme_scope_comma_at_beginning_and_end():
|
||||
theme = Theme.from_dct({
|
||||
'colors': {'foreground': '#cccccc', 'background': '#333333'},
|
||||
'tokenColors': [
|
||||
{'scope': '\n,a,b,\n', 'settings': {'fontStyle': 'italic'}},
|
||||
],
|
||||
})
|
||||
assert theme.select(('d',)).i is False
|
||||
assert theme.select(('a',)).i is True
|
||||
assert theme.select(('b',)).i is True
|
||||
|
||||
|
||||
def test_theme_scope_as_A_list():
|
||||
theme = Theme.from_dct({
|
||||
'colors': {'foreground': '#cccccc', 'background': '#333333'},
|
||||
|
||||
Reference in New Issue
Block a user