Browse Source

fix: formula identifier special character bug

pull/9775/head
Pranav C 3 weeks ago
parent
commit
747cddfdef
  1. 12
      packages/nc-gui/components/monaco/formula.ts

12
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',

Loading…
Cancel
Save