TypeFox / monaco-components

Monaco Editor and Language Client Wrapper, plus Monaco Editor React Component
MIT License
42 stars 13 forks source link

can't type newlines when `nextEmbedded` is set #49

Closed Yokozuna59 closed 10 months ago

Yokozuna59 commented 11 months ago

Hi there, in my Monarch syntax highlighter, I have a rule where it uses embedded language:

initial: [
  [
    /^\s*%%(?={)/,
    { token: 'keyword', bracket: '@open', next: '@directive', nextEmbedded: 'javascript' },
  ],
  // other rules
]

When I enter that state, I can type anything, except newlines. And when I removed javascript and made it empty, it worked fine but without the language features. I tried the code in https://microsoft.github.io/monaco-editor/monarch.html to check if the issue was in my code, but it's working fine.

Here's the minimum Monarch code:

export default {
  tokenizer: {
    initial: [
      [
        /^\s*%%(?={)/,
        { token: 'keyword', bracket: '@open', next: '@directive', nextEmbedded: 'javascript' },
      ],
    ],
    directive: [
      [/%%$/, { token: 'keyword', bracket: '@close', next: '@pop', nextEmbedded: '@pop' }],
    ],
  },
};
kaisalmen commented 11 months ago

Hi @Yokozuna59 could you please share your initialization code (UserConfig)? What editor type do you use?

Yokozuna59 commented 11 months ago

Hi @kaisalmen, I don't have one; it was the generated editor by generator-langium@2.0.0. I'm not sure if it was resolved with the latest version. I tried updating the version, but errors were thrown everywhere, so I stuck with the version that came with generator-langium. I saw that you plan to update the browser template at https://github.com/eclipse-langium/langium/issues/1163, but I'm not sure when it will happen, so I continued working with the version I have.

kaisalmen commented 11 months ago

@Yokozuna59 yes, the generator needs to be updated. Hopefully, we achieve that before Langium 2.1.0 is released. Anyway, this seems like a bug and should be verified to work or not with the current version. Thanks for reporting.

Yokozuna59 commented 10 months ago

@kaisalmen I'm not entirely sure about monarch grammar, but the issue didn't occur after updating the editor and migrated to TextMate. Thanks for your help! I'll mark the issue as resolved.