Skip to content

Commit 5bef7e2

Browse files
committed
editor/pybricksMicroPython: improve operator highlighting
This handles newer things like the := operator better.
1 parent 1db0c48 commit 5bef7e2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## [Unreleased]
66

77
### Changed
8-
- Improved syntax highlighting for numeric literals.
8+
- Improved syntax highlighting for operators and numeric literals.
99

1010
## [2.1.0-beta.2] - 2022-12-26
1111

src/editor/pybricksMicroPython.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,12 @@ export const language = <monaco.languages.IMonarchLanguage>{
180180
{ include: '@whitespace' },
181181
{ include: '@numbers' },
182182
{ include: '@strings' },
183+
[/@[a-zA-Z_]\w*/, 'tag'],
184+
[/\.\.\./, 'keyword'],
185+
[/->/, 'delimiter'],
183186
{ include: '@operators' },
184-
185-
[/[,:;]/, 'delimiter'],
187+
[/[,:.;=]/, 'delimiter'],
186188
[/[{}[\]()]/, '@brackets'],
187-
188-
[/@[a-zA-Z_]\w*/, 'tag'],
189-
190189
[
191190
/[a-zA-Z_]\w*/,
192191
{
@@ -249,7 +248,12 @@ export const language = <monaco.languages.IMonarchLanguage>{
249248
[/\\$/, 'string'],
250249
],
251250

252-
operators: [[/[=+\-*/%@&|<>!~^]/, 'keyword.operator']],
251+
operators: [
252+
[
253+
/(\*\*|\/\/|<<|>>|:=|<=|>=|==|!=|\+=|-=|\*-|\/=|\.\.=|%=|@=|&=|\|=|\^=|>>=|<<=|\*\*=|[+\-*/%@&|^~<>])/,
254+
'keyword.operator',
255+
],
256+
],
253257

254258
attributes: [
255259
[/\b/, '@pop'],

0 commit comments

Comments
 (0)