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 <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 8f58bce)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 56b8b19 commit 4fb2972
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 4fb2972

Please sign in to comment.