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

Python highlighting - raw string literals incorrectly colour escape sequences in some cases #155

Closed
aeschli opened this issue Aug 30, 2018 · 2 comments

Comments

@aeschli
Copy link

aeschli commented Aug 30, 2018

From @akdor1154 on August 30, 2018 0:54

  • VSCode Insiders Version: 1.27.0-insider 47d0584301d16d4efd6618f6f33ef14099c92561 x64

  • VSCode Stable Version: 1.26

  • OS Version: ubuntu 18.04 x64

Steps to Reproduce:

  1. Open/create a python file
  2. Write a raw string with some backslashes as a function parameter:
open(r'C:\Jenkins\new-file.xml')

Observe the backslashes are incorrectly shown as being part of an escape sequence. Raw strings literals have literal backslashes, you can't write escape sequences in them. The string should be a solid colour. \n should not be highlighted as it is in a raw string, and \J should not be highlighted as it's not even an escape sequence in a normal string (normal string highlighting behaves correctly here).
Looks like GitHub highlighting gets it wrong too. :)

image

Copied from original issue: microsoft/vscode#57555

@1st1
Copy link
Member

1st1 commented Sep 4, 2018

We highlight raw strings with Regexp syntax, that's what original users of tmLanguage schemas in TextMate and SublimeText expected. We can probably compile a special version of MagicPython that wouldn't have this feature, but then you'll get a lot of negative feedback that we broke this feature in VSCode. So as is, this isn't a bug in current MagicPython, it's a feature.

@1st1 1st1 closed this as completed Sep 4, 2018
@UncleGoogle
Copy link

UncleGoogle commented Jul 30, 2019

VSCode user here. Please reopen this issue. r'strings' are string literals, not the regex literals! It can be used for example for windows filesystem paths without manually changing every slash to double slash...

I know that it is used often in regex. But this feature should be handle differently. At least provide some config, to set it manually.

Snippet below doesn't looks like a feature at all.

1ccc3b6b8d95c07eda9806d4b0831b7c

EDIT
I've just read #149
So I can use bit R instead of r. But still...

89636f8f832036b2d0046666a9dfe5ac

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

3 participants