← Winnitude! Search  ·  Reader Mode (1212 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 7 LINKS

Syntax Highlighting regex+format strings (rf) · Issue #256 · MagicStack/MagicPython

Repository navigation

Syntax Highlighting regex+format strings (rf)  #256


New issue

New issue

Open

Open
Syntax Highlighting regex+format strings (rf) #256

Description

@brownjoel's profile brownjoel opened on Feb 27, 2023
  • 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 :
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions