Skip to content

Commit 55526bb

Browse files
committed
fix(engine): regex flags propagation
1 parent 61a6bf2 commit 55526bb

File tree

11 files changed

+2706
-83
lines changed

11 files changed

+2706
-83
lines changed

packages/core/src/engines/javascript.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export class JavaScriptScanner implements PatternScanner {
2727
p
2828
// YAML specific handling; TODO: move to tm-grammars
2929
.replaceAll('[^\\s[-?:,\\[\\]{}#&*!|>\'"%@`]]', '[^\\s\\-?:,\\[\\]{}#&*!|>\'"%@`]'),
30-
{ flags: 'dgm' },
30+
{
31+
flags: 'dgm',
32+
ignoreContiguousAnchors: true,
33+
},
3134
)
3235
cache?.set(p, regex)
3336
return regex
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
[
2+
{
3+
"constractor": [
4+
[
5+
"\\b(?:true|false|null)\\b",
6+
"-?(?:0|[1-9]\\d*)(?:(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)?",
7+
"\"",
8+
"\\[",
9+
"\\{",
10+
"/\\*\\*(?!/)",
11+
"/\\*",
12+
"(//).*$\\n?"
13+
]
14+
],
15+
"executions": [
16+
{
17+
"args": [
18+
"// comment\n",
19+
0
20+
],
21+
"result": {
22+
"index": 7,
23+
"captureIndices": [
24+
{
25+
"start": 0,
26+
"end": 11,
27+
"length": 11
28+
},
29+
{
30+
"start": 0,
31+
"end": 2,
32+
"length": 2
33+
}
34+
]
35+
}
36+
},
37+
{
38+
"args": [
39+
"// comment\n",
40+
11
41+
],
42+
"result": null
43+
},
44+
{
45+
"args": [
46+
"{\"foo\":\"bar\"}\n",
47+
0
48+
],
49+
"result": {
50+
"index": 4,
51+
"captureIndices": [
52+
{
53+
"start": 0,
54+
"end": 1,
55+
"length": 1
56+
}
57+
]
58+
}
59+
},
60+
{
61+
"args": [
62+
"{\"foo\":\"bar\"}\n",
63+
13
64+
],
65+
"result": null
66+
}
67+
]
68+
},
69+
{
70+
"constractor": [
71+
[
72+
"\\}",
73+
"\"",
74+
"/\\*\\*(?!/)",
75+
"/\\*",
76+
"(//).*$\\n?",
77+
":",
78+
"[^\\s\\}]"
79+
]
80+
],
81+
"executions": [
82+
{
83+
"args": [
84+
"{\"foo\":\"bar\"}\n",
85+
1
86+
],
87+
"result": {
88+
"index": 1,
89+
"captureIndices": [
90+
{
91+
"start": 1,
92+
"end": 2,
93+
"length": 1
94+
}
95+
]
96+
}
97+
},
98+
{
99+
"args": [
100+
"{\"foo\":\"bar\"}\n",
101+
6
102+
],
103+
"result": {
104+
"index": 5,
105+
"captureIndices": [
106+
{
107+
"start": 6,
108+
"end": 7,
109+
"length": 1
110+
}
111+
]
112+
}
113+
},
114+
{
115+
"args": [
116+
"{\"foo\":\"bar\"}\n",
117+
12
118+
],
119+
"result": {
120+
"index": 0,
121+
"captureIndices": [
122+
{
123+
"start": 12,
124+
"end": 13,
125+
"length": 1
126+
}
127+
]
128+
}
129+
}
130+
]
131+
},
132+
{
133+
"constractor": [
134+
[
135+
"\"",
136+
"\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4})",
137+
"\\\\."
138+
]
139+
],
140+
"executions": [
141+
{
142+
"args": [
143+
"{\"foo\":\"bar\"}\n",
144+
2
145+
],
146+
"result": {
147+
"index": 0,
148+
"captureIndices": [
149+
{
150+
"start": 5,
151+
"end": 6,
152+
"length": 1
153+
}
154+
]
155+
}
156+
}
157+
]
158+
},
159+
{
160+
"constractor": [
161+
[
162+
"(,)|(?=\\})",
163+
"\\b(?:true|false|null)\\b",
164+
"-?(?:0|[1-9]\\d*)(?:(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)?",
165+
"\"",
166+
"\\[",
167+
"\\{",
168+
"/\\*\\*(?!/)",
169+
"/\\*",
170+
"(//).*$\\n?",
171+
"[^\\s,]"
172+
]
173+
],
174+
"executions": [
175+
{
176+
"args": [
177+
"{\"foo\":\"bar\"}\n",
178+
7
179+
],
180+
"result": {
181+
"index": 3,
182+
"captureIndices": [
183+
{
184+
"start": 7,
185+
"end": 8,
186+
"length": 1
187+
}
188+
]
189+
}
190+
},
191+
{
192+
"args": [
193+
"{\"foo\":\"bar\"}\n",
194+
12
195+
],
196+
"result": {
197+
"index": 0,
198+
"captureIndices": [
199+
{
200+
"start": 12,
201+
"end": 12,
202+
"length": 0
203+
},
204+
{
205+
"start": 4294967295,
206+
"end": 4294967295,
207+
"length": 0
208+
}
209+
]
210+
}
211+
}
212+
]
213+
},
214+
{
215+
"constractor": [
216+
[
217+
"\"",
218+
"\\\\(?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4})",
219+
"\\\\."
220+
]
221+
],
222+
"executions": [
223+
{
224+
"args": [
225+
"{\"foo\":\"bar\"}\n",
226+
8
227+
],
228+
"result": {
229+
"index": 0,
230+
"captureIndices": [
231+
{
232+
"start": 11,
233+
"end": 12,
234+
"length": 1
235+
}
236+
]
237+
}
238+
}
239+
]
240+
}
241+
]

packages/shiki/test/engine-js/__records__/sql.json

Lines changed: 575 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)