Fixes microsoft/monaco-editor#1818: check matchOnlyAtLineStart when e… by bolinfest · Pull Request #90266 · microsoft/vscode

I tested this by copying one of the .html files in playground.generated and changing the JavaScript to include the following:

const DEMO_LANG_ID = "demo";

const languageConfiguration = {
  // The main tokenizer for our languages
  tokenizer: {
    root: [
      [/^\!/, { token: 'delimiter.curly', next: 'jsonInBang', nextEmbedded: 'json' }],
    ],
    jsonInBang: [
      [/^\!/, { token: 'delimiter.curly', next: '@pop', nextEmbedded: '@pop' }],
    ],
  },
};
monaco.languages.register({
  id: DEMO_LANG_ID,
  extensions: ['.example'],
});
monaco.languages.setMonarchTokensProvider(DEMO_LANG_ID, languageConfiguration);

      const value = `\
!
  {
    "foo": "b!ar"
  }
!
`;

var editor = monaco.editor.create(document.getElementById("container"), {
  value,
  language: DEMO_LANG_ID,

  lineNumbers: "off",
  roundedSelection: false,
  scrollBeyondLastLine: false,
  readOnly: false,
  theme: "vs-dark",
});

When I loaded the page, now the entire "b!ar" string literal was highlighted correctly. Previously, the syntax highlighting stopped at the !.