Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Raw strings + convoluted escaping = broken string highlighting #2

@cpfair

Description

@cpfair

Take this bit of entirely valid python code

contrived_regex = r"\*text\*\n\*text\*\n\*text\*\n\*text\*\n\*(?P<label1>.+)\n(?P<label2>.+)\n(?P<label3>.+\((?P<label4>[A-Z]*)\))\n(?P<label5>.+)\n(?P<label6>.+\((?P<label7>[A-Z]{3})\))\n(?P<label8>.+)\n(?P<label9>\d+)\n"
innocent_variable = {
  "things": 123
}

Here's what it looks like in Atom

Atom

vs. in ST2

ST2

In a few minutes of experimentation, that was the shortest I could get the troublemaking string down to. Removing the raw decorator, or removing (nearly?) any of the control characters inside it fixes the highlighting.

Edit: slightly shorter variant that produces the same result:

contrived_regex = r"\*\text\*\\*\text\*\\*\\text\\n\*\\text\*\n\*(?P<label1>.+)\n(?P<label2>.+)\n(?P<label3>.+\((?P<label4>[]*)\))\n(?P<label5>.+)\n(.+\((?P<label7>[a]{)\))\n(?P<label8>.+)\n(?P<label9>\d+)"
innocent_variable = {
  "things": 123
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions