I drafted following tokenizer for Monaco Editor Highlighting:
tokenizer: {
root: [
[/,\s+/, { token: 'default', next: '@test', log: 'iuhhh'}],
[/^.{0,71}/, { token: 'default', log: 'kkkkk'}]
],
test: [
[/.*/, { token: 'comment', log: 'kjhgf', next: '@pop'}]
],
},
when I try the ddd, ddddddd
, it doesn't match the first rule, go to the [/^.{0,71}/, { token: 'default', log: 'kkkkk'}]
directly. Why it doesn't match the first rule?
Please see the picture for more details:
This is easy to understand, because monaco editor matches from the beginning. Your text starts with "dd", which does not comply with the first rule, so monaco editor goes directly to the second rule and eats all the text.