0

I'm using a vscode customized theme that I changed to fit my needs, which I based on github dark for scopes. I'm finally in a spot I find it nice looking but I have a problem with fstring quotes, they simply don't get colored.

Prints sequence

I've tried some scopes and just the punctuation.definition.string.begin/end worked. When I tried using the meta.fstring.python it changed the whole string color, quotes and text inside. The strange is that the raw (r"") strings work. Also there's this bug with the {var} inside the raw one.

Tried MagicPython to see if any of their Scopes work, but it didn't

Any suggestions as to which should I use to fix it?

Vinicius
  • 55
  • 9
  • What do you mean "they simply don't get colored"? Which part of the screenshot are you talking about? It looks pretty coloured to me. – starball Feb 09 '23 at 19:29
  • Why would `{var}` work inside straight raw strings? That construct doesn't have any special meaning in Python. It only works in regular strings (using string formatting) and f-strings. It's working in your last line because it's an f-string, not because it's a raw string. – MattDMo Feb 09 '23 at 19:36
  • @user look at the quotation marks. In the first 3 strings, the quote marks are a different color than the string contents. In the last two f-strings, they're not. – MattDMo Feb 09 '23 at 19:38
  • @MattDMo ah my apologies. I should have read more carefully! – starball Feb 09 '23 at 19:39
  • @MattDMo I see, I didn't know about that, I apologise, thank you for explaining. And it's as Matt said, the fstring quotes didn't get colored. – Vinicius Feb 10 '23 at 17:01
  • Which Python syntax/plugin are you using? – MattDMo Feb 10 '23 at 17:01
  • Is there a way to check that? I think it is Pylance – Vinicius Feb 10 '23 at 17:23

1 Answers1

1

I got it to work, had to specify the scope more explicitly.

The order of the scopes in the Visual Studio Code theme file determines the order in which they are applied. To make the punctuation.definition.string.begin.python scope take precedence over the string.quoted.single.python scope, you need to ensure that the former is defined after the latter.

However, even if the scopes are defined in the correct order, there can be a conflict if one of the scopes is more specific than the other. In this case, the string.quoted.single.python scope is more specific than the punctuation.definition.string.begin.python scope, so it will be applied instead. To address this, you can make the punctuation.definition.string.begin.python scope more specific by including string.quoted.single.python as a sub-scope.

    "punctuation.definition.string.begin.python string.interpolated.python",
    "punctuation.definition.string.begin.python string.quoted.double.python",
    "punctuation.definition.string.begin.python string.quoted.single.python",
    "punctuation.definition.string.end.python string.interpolated.python",
    "punctuation.definition.string.end.python string.quoted.double.python",
    "punctuation.definition.string.end.python string.quoted.single.python"

This way, it works

image

Vinicius
  • 55
  • 9