• Login
Community
  • Login

Python 3 f-strings not colourizing correctly

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 3 Posters 1.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    Peter L
    last edited by Mar 25, 2020, 6:20 AM

    Python 3 f-strings aren’t colourizing correctly on my version of Notepad++
    I have v7.8.5 on Win10
    This issue was corrected in patch 5698 around May 2019
    https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5698
    But I’m still have f-strings showing with the wrong syntax colouring. I have changed the colours from the default.

    6cb554b7-dd97-4910-a886-5ab1bb322a68-image.png

    I’m also unsure if there’s supposed to be an entry specifically for f-strings in the configurator (there isn’t on mine).

    c8f98f03-e8f0-4603-867c-316ea49b8f65-image.png

    I’ve had a look in the stylers.model.xml file, and it looks how I thought it should (same as https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/stylers.model.xml )

            <LexerType name="python" desc="Python" ext="">
                <WordsStyle name="DEFAULT" styleID="0" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="COMMENTLINE" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="NUMBER" styleID="2" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="STRING" styleID="3" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="CHARACTER" styleID="4" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="KEYWORDS" styleID="5" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre1" />
                <WordsStyle name="BUILTINS" styleID="14" fgColor="880088" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" keywordClass="instre2" />
                <WordsStyle name="TRIPLE" styleID="6" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="TRIPLEDOUBLE" styleID="7" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="CLASSNAME" styleID="8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
                <WordsStyle name="DEFNAME" styleID="9" fgColor="FF00FF" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="OPERATOR" styleID="10" fgColor="000080" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
                <WordsStyle name="IDENTIFIER" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="COMMENTBLOCK" styleID="12" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="DECORATOR" styleID="15" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="2" fontSize="" />
                <WordsStyle name="F STRING" styleID="16" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="F CHARACTER" styleID="17" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="F TRIPLE" styleID="18" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
                <WordsStyle name="F TRIPLEDOUBLE" styleID="19" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
            </LexerType>
    
    

    Any one have any ideas? Is this a regression bug from May last year?
    Thanks for your help and ideas.
    Peter

    A 1 Reply Last reply Mar 25, 2020, 12:23 PM Reply Quote 1
    • A
      Alan Kilborn @Peter L
      last edited by Mar 25, 2020, 12:23 PM

      @Peter-L

      It seems to work for me in 7.8.5:

      c66d2ac8-ee6f-424c-967c-50e556e4ed4d-image.png

      Not sure, but maybe it is an upgrade issue – if you customize something, when upgrading Notepad++ doesn’t want to blow away that customization…so you don’t get any enhancements for something like this? Again, not sure as I only use portable versions of Notepad++ and update them very manually and carefully when I change versions.

      1 Reply Last reply Reply Quote 3
      • P
        PeterJones
        last edited by Mar 25, 2020, 1:56 PM

        @Alan-Kilborn said in Python 3 f-strings not colourizing correctly:

        if you customize something, when upgrading Notepad++ doesn’t want to blow away that customization…so you don’t get any enhancements for something like this?

        I’m quite sure that’s what’s happening.

        @Peter-L ,
        The quick fix for python-highlighting only would be to edit your local stylers.xml and add the four f-string lines to the python lexer config:

                                <WordsStyle name="F STRING" styleID="16" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />            
                                <WordsStyle name="F CHARACTER" styleID="17" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />            
                                <WordsStyle name="F TRIPLE" styleID="18" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />            
                                <WordsStyle name="F TRIPLEDOUBLE" styleID="19" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
        

        then save the file and exit Notepad++ and re-run Notepad++.

        A more complete solution across every lexer language would be to open <installdir>\stylers.model.xml in one pane and %appdata%\notepad++\stylers.xml in the other, do a diff (Compare Plugin or similar) and bring over any new lines from the stylers.model.xml into your local stylers.xml – you don’t need to change the color or font settings on existing ones, in case you’ve customized those; just bring over the missing WordsStyle entries for each language (and bring over any missing languages, too).

        I know that can seem like a pain to have to do when notepad++ updates, but as Alan mentioned,

        [Notepad++ upgrade] doesn’t want to blow away that customization

        Unfortunately, trying to automate that diff procedure, and being able to determine what’s a user-customization and what’s just a change in the available settings is a rather difficult programming challenge, and more than most premade installer/upgrader executables are able to handle.

        ----

        Oh, and @Peter-L , I wanted to say, thanks for providing a well-researched problem statement; it was obvious with your links to the issues page, the screenshots, and the xml excerpt, that you put a lot of thought into asking your question – that’s a refreshing change of pace to some of the questions and demands we see here, so thank you.

        P 1 Reply Last reply Mar 26, 2020, 12:40 AM Reply Quote 3
        • P
          Peter L @PeterJones
          last edited by Mar 26, 2020, 12:40 AM

          Yes! That’s it. All working perfectly now.
          Yes, you’re quite correct, I have customised the settings (quite a bit), so that’s what’s happening.
          I’ll be aware of that for future issues.
          It may well be simpler for me to keep a track of my customisations, then uninstall and reinstall Notepad++ for a new upgrade, along the lines of what @Alan-Kilborn does with his portable version.
          And thank you @PeterJones for your kind comments.

          1 Reply Last reply Reply Quote 4
          1 out of 4
          • First post
            1/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors