Skip to content

Commit 5b1dce2

Browse files
authored
Merge pull request #8 from dgehlich/fix-dollar-quotes-multiline
Improved dollar quotes for multiline support
2 parents 8321a50 + 5fddb45 commit 5b1dce2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

PostgreSQL.YAML-tmLanguage

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ repository:
8484
dollar_quotes:
8585
patterns:
8686
- comment: "Assume multiline dollar quote is SQL body!
87-
Start if double dollar quote is followed by no dollar quote till line ending.
87+
Start if double dollar quote is followed by comment (-- or /**/) or linebreak (\n or \r).
8888
See match for dollar quotes as string: string.unquoted.dollar.pgsql.
8989
This could easily support other PL languages like PHP and Ruby -- see PHP heredoc as an example."
9090
# name: meta.dollar-quote.pgsql
9191
contentName: meta.dollar-quote.pgsql
92-
begin: (\$[\w_]*\$)(?=[^\$]*$)
92+
begin: (\$[\w_]*\$)(?=\s*[-\/\n\r]+)
9393
beginCaptures:
9494
'1': {name: punctuation.dollar-quote.begin.pgsql}
9595
end: \1
@@ -191,9 +191,8 @@ repository:
191191
- comment: Double quoting treated like strings, but they are really identifiers.
192192
name: variable.other.pgsql
193193
match: (")[^"#]*(")
194-
- comment: "Color dollar double quotes as a string if in one line.
195-
No multiline supported because function body is with dollar quotes,
196-
see meta.dollar-quote.pgsql."
194+
- comment: "Color double dollar quotes as a string
195+
Only if not followed by comment or linebreak, see meta.dollar-quote.pgsql."
197196
name: string.unquoted.dollar.pgsql
198197
begin: (\$[\w_]*\$)
199198
end: \1

PostgreSQL.tmLanguage

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<array>
9696
<dict>
9797
<key>begin</key>
98-
<string>(\$[\w_]*\$)(?=[^\$]*$)</string>
98+
<string>(\$[\w_]*\$)(?=\s*[-\/\n\r]+)</string>
9999
<key>beginCaptures</key>
100100
<dict>
101101
<key>1</key>
@@ -105,7 +105,9 @@
105105
</dict>
106106
</dict>
107107
<key>comment</key>
108-
<string>Assume multiline dollar quote is SQL body! Start if double dollar quote is followed by no dollar quote till line ending. See match for dollar quotes as string: string.unquoted.dollar.pgsql. This could easily support other PL languages like PHP and Ruby -- see PHP heredoc as an example.</string>
108+
<string>Assume multiline dollar quote is SQL body! Start if double dollar quote is followed by comment (-- or /**/) or linebreak (
109+
or
110+
). See match for dollar quotes as string: string.unquoted.dollar.pgsql. This could easily support other PL languages like PHP and Ruby -- see PHP heredoc as an example.</string>
109111
<key>contentName</key>
110112
<string>meta.dollar-quote.pgsql</string>
111113
<key>end</key>
@@ -574,7 +576,7 @@
574576
<key>begin</key>
575577
<string>(\$[\w_]*\$)</string>
576578
<key>comment</key>
577-
<string>Color dollar double quotes as a string if in one line. No multiline supported because function body is with dollar quotes, see meta.dollar-quote.pgsql.</string>
579+
<string>Color double dollar quotes as a string Only if not followed by comment or linebreak, see meta.dollar-quote.pgsql.</string>
578580
<key>end</key>
579581
<string>\1</string>
580582
<key>name</key>

0 commit comments

Comments
 (0)