GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Wrong highlight for raw string · Issue #259 · MagicStack/MagicPython

Wrong highlight for raw string #259

New issue
Copy link
New issue
Copy link
Open
Open
Wrong highlight for raw string#259
Copy link

Description

@alexr00
alexr00
opened on Aug 16, 2023
Issue body actions
  • Editor name and version: VS Code 1.81.1
  • Platform: any
  • Color scheme: any
  • MagicPython version: 7d0f2b2
  • A sreenshot:
    Expected
    image

Actual: The \ of a raw string is the \ and not the escape character, but the hignlight still treats them as escapes.
image

  • 5-10 lines of surrounding code:
print(r"C:\Users\test")

Originally from @AuroraTea in microsoft/vscode#190519

Reacted by Rob Parker, Aurik Sarker, Gilberto Agostinho, Tomokazu Katayama, DetachHead and Alf Frank

Activity

  1. goldrik commented on Sep 12, 2023

    @goldrik
    goldrik
    on Sep 12, 2023
    More actions

    The issue was mentioned here back in 2020. The link contains some extra information that may be helpful.

    The issue was closed there so that it could be reported somewhere more relevant instead, namely this repository.

  2. DG119 commented on Sep 21, 2023

    @DG119
    DG119
    on Sep 21, 2023
    More actions

    apparently it is a feature.
    Check this reply:
    #114 (comment)

    r is for RE, use R for raw string

    Reacted by Aurik Sarker
  3. gilbertohasnofb commented on Jan 6, 2024

    @gilbertohasnofb
    gilbertohasnofb
    on Jan 6, 2024
    More actions

    apparently it is a feature.
    [...]
    r is for RE, use R for raw string

    AFAIK this is not a standard defined in any PEP, and popular code formatter such as black will convert any R'' strings into r'' by default.

    I get the reasoning behind this decision, and there were some arguments for it since TextMate and Sublime Text both highlight Python syntax this way by default, but with the widespread use of VSCode these days (which does not highlight raw strings in Python this way by default) this argument seems outdated. Ideally this idiosyncratic highlighting could be made optional, preferably off by default.

    Reacted by lyhyl, DetachHead, AuroraTea, Eduardo Roberto and corybon682
  4. JelleZijlstra commented on Apr 29, 2024

    @JelleZijlstra
    JelleZijlstra
    on Apr 29, 2024
    More actions

    AFAIK this is not a standard defined in any PEP, and popular code formatter such as black will convert any R'' strings into r'' by default.

    Black specifically does not change R'' to r'' because of syntax highlighters treating the two differently. See https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#r-strings-and-r-strings.

  5. tylercowdreywadnr commented on Jan 3, 2025

    @tylercowdreywadnr
    tylercowdreywadnr
    on Jan 3, 2025
    More actions

    I struggled against this issue for a while coming from PyCharm to VSCode. Using some resources found online for editing TokenColorCustimizations and TextMateRules in the JSON settings, I was able to create a custom workaround at the link below. It's annoying having to manually enter hex codes for the colors to all match the way you'd expect inside of an r-string, but unless you are a person who changes themes often you should only have to make the edits once.

    Instructions for adding the code to your VSCode user settings are contained in the .txt file here:
    https://github.com/tylercowdreywadnr/VSCode_rstring_color_hack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.