Skip to content

Commit 00c37f9

Browse files
fixed sublime syntax highlighting
1 parent 1a9220c commit 00c37f9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/bespokeasm/configgen/sublime/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import tempfile
66
from zipfile import ZipFile
77

8-
from ruamel.yaml import YAML
9-
108
import bespokeasm.configgen.sublime.resources as resources
119
from bespokeasm.assembler.keywords import BYTECODE_DIRECTIVES_SET
1210
from bespokeasm.assembler.keywords import COMPILER_DIRECTIVES_SET
1311
from bespokeasm.assembler.keywords import EXPRESSION_FUNCTIONS_SET
1412
from bespokeasm.assembler.keywords import PREPROCESSOR_DIRECTIVES_SET
1513
from bespokeasm.configgen import LanguageConfigGenerator
14+
from ruamel.yaml import YAML
1615

1716

1817
class SublimeConfigGenerator(LanguageConfigGenerator):
@@ -141,7 +140,8 @@ def _generate_files_in_dir(self, destination_dir: str) -> None:
141140
syntax_dict['contexts']['data_types_directives'][0]['match'] = datatypes_str.replace('##DATATYPES##', datatypes_regex)
142141

143142
# preprocessor directives
144-
preprocessor_regex = '|'.join(PREPROCESSOR_DIRECTIVES_SET)
143+
# Sort by length (desc) to avoid prefix matches like 'if' matching 'ifdef'
144+
preprocessor_regex = '|'.join(sorted(PREPROCESSOR_DIRECTIVES_SET, key=len, reverse=True))
145145
updated = False
146146
for rule in syntax_dict['contexts']['preprocessor_directives'][0]['push']:
147147
if 'match' in rule and '##PREPROCESSOR##' in rule['match']:

src/bespokeasm/configgen/sublime/resources/sublime-syntax.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ contexts:
185185
scope: punctuation.definition.preprocessor
186186
push:
187187
- meta_scope: meta.preprocessor
188-
- match: (?<=\#)(?:##PREPROCESSOR##)
188+
- match: (?<=\#)(?:##PREPROCESSOR##)\b
189189
scope: keyword.control.preprocessor
190190
- include: strings
191191
- include: numerical_expressions

0 commit comments

Comments
 (0)