Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong highlight for raw string #259

Open
alexr00 opened this issue Aug 16, 2023 · 4 comments
Open

Wrong highlight for raw string #259

alexr00 opened this issue Aug 16, 2023 · 4 comments

Comments

@alexr00
Copy link

alexr00 commented Aug 16, 2023

  • 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

@goldrik
Copy link

goldrik commented Sep 12, 2023

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.

@DG119
Copy link

DG119 commented Sep 21, 2023

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

r is for RE, use R for raw string

@gilbertohasnofb
Copy link

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.

@JelleZijlstra
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants