Skip to content

Commit

Permalink
[Python] Fix double quoted u-string scope
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Dec 13, 2023
1 parent 9ff949b commit 4b36557
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Python/Python.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -3188,7 +3188,7 @@ contexts:

double-quoted-u-string-body:
- meta_include_prototype: false
- meta_content_scope: meta.string.python string.quoted.double.block.python
- meta_content_scope: meta.string.python string.quoted.double.python
- include: double-quoted-string-end
- include: double-quoted-u-string-syntax

Expand Down
13 changes: 13 additions & 0 deletions Python/tests/syntax_test_python_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,30 @@
# ^ keyword.other.DML.sql

conn.execute(U"SELECT * FROM foobar")
# ^ meta.string.python string.quoted.double.python punctuation.definition.string.begin.python
# ^^^^^^^^^^^^^^^^^^^^ meta.string.python source.sql
# ^ meta.string.python string.quoted.double.python punctuation.definition.string.end.python
# ^ keyword.other.DML.sql

conn.execute(U'SELECT * FROM foobar')
# ^ meta.string.python string.quoted.single.python punctuation.definition.string.begin.python
# ^^^^^^^^^^^^^^^^^^^^ meta.string.python source.sql
# ^ meta.string.python string.quoted.single.python punctuation.definition.string.end.python
# ^ keyword.other.DML.sql

# In this example, the Python string is not raw, so \t is a python escape
conn.execute(u"SELECT * FROM foobar WHERE foo = '\t'")
# ^ storage.type.string.python
# ^ meta.string.python string.quoted.double.python punctuation.definition.string.begin.python
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.python source.sql
# ^ keyword.other.DML.sql
# ^ constant.character.escape.python
# ^ meta.string.python string.quoted.double.python punctuation.definition.string.end.python

conn.execute(u'SELECT * FROM foobar')
# ^ meta.string.python string.quoted.single.python punctuation.definition.string.begin.python
# ^^^^^^^^^^^^^^^^^^^^ meta.string.python source.sql
# ^ meta.string.python string.quoted.single.python punctuation.definition.string.end.python
# ^ keyword.other.DML.sql

# In this example, the Python string is raw, so the \b should be a SQL escape
Expand Down

0 comments on commit 4b36557

Please sign in to comment.