MagicStack / MagicStack/MagicPython
Syntax Highlighting regex+format strings (rf)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
* **Editor name and version**: VSCode 1.75.1
* **Platform**: macOS
* **Color scheme**: Dark+ (default)
* **MagicPython version**: 1.1.0
* **A sreenshot**:

* **5-10 lines of surrounding code**:
```python
myString = "baz"
MYCONST = "qux"
myDict = {
"foo": "bar"
}
correctColoring = rf"(?=[\w]+){myString}{MYCONST}[\d]+"
incorrectDictionary = rf"(?=[\w]+){myDict['foo']}[\d]+"
regularFString = f"word{myDict['foo']}number"
```
This is a followup to #186. After upgrading to 1.1.0, I'm very excited that rf strings support both regex style and format string. In the attached screenshot, behold how correctly varied `correctColoring` is. However, any dictionary or class inside of the {} in an rf string is not colored correctly. See how `myDict['foo']` varies between `incorrectDictionary` and `regularFString`. The square brackets should be purple, and 'foo' orange, but instead it is all absorbed into red.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the rf-string examples in this issue and compare the highlighting behavior of myDict['foo'] with the regular f-string example. Review the implementation related to the follow-up in issue #186, reproduce the incorrect coloring in VSCode, and consider the issue done when dictionary or class expressions inside rf-string format fields are highlighted consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, vscode
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100