Skip to content

Commit

Permalink
[Python] Fix double quoted u-string scope (#3889)
Browse files Browse the repository at this point in the history
This commit fixes a copy & paste error, which caused `block` scope to having been found its way to normal double quoted u-strings.
  • Loading branch information
deathaxe authored Dec 14, 2023
1 parent 8b99823 commit 36d3f0e
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 36d3f0e

Please sign in to comment.