Search code examples
visual-studio-codescopevscode-extensionstmlanguage

fstring quotes scope vscode theme


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?


Solution

  • 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