Skip to content

Commit

Permalink
Fix: Handle triple quotes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
WilsonZiweiWang committed Nov 28, 2023
1 parent 1794a13 commit 4d0943a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
19 changes: 19 additions & 0 deletions client/syntaxes/bitbake.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,25 @@
},
"string": {
"patterns": [
{
"name": "string.quoted.triple.bb",
"begin": "(\"\"\")",
"end": "(\"\"\")",
"patterns": [
{
"include": "#escaped-single-quote"
},
{
"include": "#escaped-double-quote"
},
{
"include": "#inline-python"
},
{
"include": "#variable-expansion"
}
]
},
{
"name": "string.quoted.double.bb",
"begin": "(\")",
Expand Down
6 changes: 6 additions & 0 deletions client/test/grammars/snaps/strings.bb
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ INHERIT += "autotools pkgconfig"
MYVAR = "This string contains escaped double quote \" and it should not break the highlight"

MYVAR = 'This string contains escaped single quote \' and it should not break the highlight'

MYVAR = """
nested " quotes shoudn't change the highlighting
"""

TEST_TRIPLE_QUOTES = 'the highlighting for this line which follows the triple quotes should still work correctly'
15 changes: 15 additions & 0 deletions client/test/grammars/test-cases/strings.bb
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,18 @@
# ^^ source.bb string.quoted.single.bb constant.character.escape.bb
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.bb string.quoted.single.bb
# ^ source.bb string.quoted.single.bb

>MYVAR = """
# ^^^ source.bb string.quoted.triple.bb
>nested " quotes shoudn't change the highlighting
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.bb string.quoted.triple.bb
>"""
#^^^ source.bb string.quoted.triple.bb
>
>TEST_TRIPLE_QUOTES = 'the highlighting for this line which follows the triple quotes should still work correctly'
#^^^^^^^^^^^^^^^^^^ source.bb variable.other.names.bb
# ^ source.bb keyword.operator.bb
# ^ source.bb string.quoted.single.bb
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.bb string.quoted.single.bb
# ^ source.bb string.quoted.single.bb
>

0 comments on commit 4d0943a

Please sign in to comment.