forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
feature-requestRequest for new features or functionalityRequest for new features or functionalitytriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Description
\n in print("Hello\nWorld!") isn't highlighted. In fact any escape sequence, valid or invalid, isn't highlighted.
This causes confusion and hidden bugs when working with Windows paths.
path = "C:\Program Files"
print(path)
# Output:
# C:\Program Files
# <>:1: SyntaxWarning: "\P" is an invalid escape sequence. Such sequences will not work in ## the future. Did you mean "\\P"? A raw string is also an option.
# <>:1: SyntaxWarning: "\P" is an invalid escape sequence. Such sequences will not work in ## the future. Did you mean "\\P"? A raw string is also an option.
# /tmp/ipykernel_8389/650748438.py:1: SyntaxWarning: "\P" is an invalid escape sequence. # Such sequences will not work in the future. Did you mean "\\P"? A raw string is also an # option.
# path = "C:\Program Files"Proposal:
Every backslash (\) outside of a raw string must be treated as a meta-character and highlighted accordingly.
Additionally, any valid sequence of one or more non-white-space characters immediately following the backslash should be highlighted to indicate a recognized escape sequence.
| String Context | Code | Highlight Behavior |
|---|---|---|
| Standard | "Line\n" |
\ is Meta-color & n is escape color. |
| Standard: Hex | "\xff" |
\ is Meta-color & xff is escape color. |
| Raw | r"Line\n" |
\ and n are both standard string color. |
| Invalid | "\P" |
\ is Meta-color & P is warning/error color. |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature-requestRequest for new features or functionalityRequest for new features or functionalitytriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team