diff --git a/changelogs/fragments/8951.yml b/changelogs/fragments/8951.yml new file mode 100644 index 000000000000..da724b7d3c66 --- /dev/null +++ b/changelogs/fragments/8951.yml @@ -0,0 +1,2 @@ +fix: +- SQL syntax highlighting double quotes ([#8951](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8951)) \ No newline at end of file diff --git a/packages/osd-monaco/src/xjson/lexer_rules/opensearchsql.ts b/packages/osd-monaco/src/xjson/lexer_rules/opensearchsql.ts index 0ff29b71c09d..6697b3592c15 100644 --- a/packages/osd-monaco/src/xjson/lexer_rules/opensearchsql.ts +++ b/packages/osd-monaco/src/xjson/lexer_rules/opensearchsql.ts @@ -134,18 +134,22 @@ export const lexerRules = { [new RegExp(operators.join('|')), 'operator'], [/[0-9]+(\.[0-9]+)?/, 'number'], [/'([^'\\]|\\.)*$/, 'string.invalid'], // non-terminated string - [/'/, 'string', '@string'], - [/"/, 'string', '@string'], + [/'/, 'string', '@stringSingle'], + [/"/, 'string', '@stringDouble'], ], whitespace: [ [/[ \t\r\n]+/, 'white'], [/\/\*/, 'comment', '@comment'], [/--.*$/, 'comment'], ], - string: [ + stringSingle: [ [/[^'\\]+/, 'string'], [/\\./, 'string.escape'], [/'/, 'string', '@pop'], + ], + stringDouble: [ + [/[^"\\]+/, 'string'], + [/\\./, 'string.escape'], [/"/, 'string', '@pop'], ], comment: [