diff --git a/packages/nc-gui/components/monaco/formula.ts b/packages/nc-gui/components/monaco/formula.ts index fd50a86373..ff95ed8388 100644 --- a/packages/nc-gui/components/monaco/formula.ts +++ b/packages/nc-gui/components/monaco/formula.ts @@ -43,7 +43,17 @@ const generateLanguageDefinition = (identifiers: string[]) => { [/"/, { token: 'string.quote', bracket: '@open', next: '@dblString' }], [/'/, { token: 'string.quote', bracket: '@open', next: '@sglString' }], [ - new RegExp(`\\{(${identifiers.join('|').replace(/[{}]/g, '')})\\}`), + new RegExp( + `\\{(${identifiers + .map((identifier) => + identifier + // remove curly braces wrapping the identifier + .replace(/^\{([\s\S]+)\}$/, '$1') + // escape special characters + .replace(/[.*+?^${}()|[\]\\-]/g, '\\$&'), + ) + .join('|')})\\}`, + ), { cases: { '@identifiers': 'identifier',