Skip to content

Commit

Permalink
[Auto Suggest] SQL Syntax Highlighting fix (#8951)
Browse files Browse the repository at this point in the history
Fixes SQL monaco monarch tokens by separating the states for single quoted and double quoted strings so that both can appear properly

---------

Signed-off-by: Paul Sebastian <paulstn@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
paulstn and opensearch-changeset-bot[bot] authored Nov 27, 2024
1 parent c24d5bc commit 8f58bce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8951.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- SQL syntax highlighting double quotes ([#8951](/~https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8951))
10 changes: 7 additions & 3 deletions packages/osd-monaco/src/xjson/lexer_rules/opensearchsql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 8f58bce

Please sign in to comment.