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

UDL import causes **fontName** to be corrupted in userDefineLang.xml and/or UDL export #5630

Open
pryrt opened this issue May 7, 2019 · 4 comments
Labels
udl Everything related to User Defined Language

Comments

@pryrt
Copy link
Contributor

pryrt commented May 7, 2019

Per Community Forum #17574, UDL import seems to have a bug with importing a language causing UDL to mess up the fontName settings.

Forum member "@Karsten75" started with an UDL-XML file to import:

<NotepadPlus>
    <UserLang name="smol" ext="smol" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
            <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">00# 01 02 03 04</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2"></Keywords>
            <Keywords name="Numbers, extras1"></Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2"></Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1">-&gt; &lt;- [ ] ( ) { } </Keywords>
            <Keywords name="Operators2">and or xor not</Keywords>
            <Keywords name="Folders in code1, open">Do While Once</Keywords>
            <Keywords name="Folders in code1, middle">Else</Keywords>
            <Keywords name="Folders in code1, close">Loop  endwhile endonce</Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">add sub mul div</Keywords>
            <Keywords name="Keywords2">Pi Tau I J K Distance cos Atan Log10</Keywords>
            <Keywords name="Keywords3"></Keywords>
            <Keywords name="Keywords4"></Keywords>
            <Keywords name="Keywords5"></Keywords>
            <Keywords name="Keywords6"></Keywords>
            <Keywords name="Keywords7"></Keywords>
            <Keywords name="Keywords8"></Keywords>
            <Keywords name="Delimiters"></Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="Calibri" fontStyle="0" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontStyle="2" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="FF8080" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="FF8080" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="0080C0" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="808040" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

When that user imported the UDL, then exported it, the export had corrupted fontName.

I tried two experiments, as described in my post there, and re-described here:

My Experiment 1:

  • unzip a fresh 7.6.6 64-bit into ...\npp.7.6.6.bin.x64\
  • save @Karsten75's example as ...\npp.7.6.6.bin.x64\userDefineLangs\smol.xml
  • run that edition of Notepad++, and see the 'smol' in the list of user defined languages
  • export the UDL to exportSmol.xml (somewhere)
  • run a compare on smol.xml and exportSmol.xml: the only difference was that exportSmol.xml had a bunch of fontName="", whereas the source didn't have those tags at all (except for the one fontName="Calibri")

That one worked the way I expected.

Experiment 2:

  • close notepad++

  • delete ...\npp.7.6.6.bin.x64\userDefineLangs\smol.xml

  • save original example to importSmol.xml

  • run that edition of Notepad++, do Language > Define your language > import..., and smol shows up.

  • exit Notepad++l, and re-run that edition of Notepad++.

  • Look at ...\npp.7.6.6.bin.x64\userDefineLang.xml: it has smol, but as @Karsten75 described, the fontName="..." settings are corrupted:

          <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="&#xA1E0;&#xF7FC;&#x020F;" fontStyle="0" nesting="0" />
          <WordsStyle name="COMMENTS" fgColor="000000" bgColor="FFFFFF" fontName="-1" fontStyle="0" nesting="0" />
          <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="Backup" fontStyle="2" nesting="0" />
          <WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontName="0" fontStyle="0" nesting="0" />
          <WordsStyle name="KEYWORDS1" fgColor="FF8080" bgColor="FFFFFF" fontName="no" fontStyle="0" nesting="0" />
          <WordsStyle name="KEYWORDS2" fgColor="FF8080" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
          <WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontName="no" fontStyle="0" nesting="0" />
          <WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontName="MRU" fontStyle="0" nesting="0" />
    

My actions seem to confirm the bug that @Karsten75 reported in the forum.

This may be the behavior that @jensensen saw in #5501...

@E3V3A
Copy link

E3V3A commented Jan 12, 2020

Would be great to have a working template for this file.
Where is this file coming from anyway?
Like the OP I also notice this corruption and worse, when you edit it and re-import it, the changes are lost WTF!??

@pryrt
Copy link
Contributor Author

pryrt commented Jan 12, 2020

Would be great to have a working template for this file.

The working template for the file can be generated by using the User Defined Lanugage dialog box to create a language in the first place. Or through the userDefinedLang-markdown.default.modern.xml file that's included when you install Notepad++.

when you edit it and re-import it, the changes are lost

As it says in the npp-user-manual on the Configuration Files Details page:

If changes are made in the Notepad++ UI to settings which are stored in configuration files, those will be written to disk when you exit Notepad++ after any file saves you do. Thus, if you are going to edit a Notepad++ configuration file with Notepad++ (and why would you want to edit it with anything else?), you will need to be careful.

It then goes on to describe the safest sequence for editing a Notepad++ configuration file inside Notepad++.

The primary method of editing Notepad++ configuration (including UDL) is through the GUI interface. If you choose not to edit it that way, the onus is on you to do things correctly.

WTF

Wow. Curse at the volunteers who are able to help you: great way to try to get help or get your request implemented.

@donho
Copy link
Member

donho commented Jan 13, 2020

@E3V3A This is an open source project, that means you can do your contribution to fix it... If you are not capable, you can ask people whom you don't pay nicely.

@ied206
Copy link

ied206 commented Feb 27, 2021

I am still experiencing similar issues with my own UDL files.
When I import the XML file within Notepad++ GUI, fonts are garbled just like @pryrt reported.
The only way to avoid this issue right now is to copy the XML files directly into %AppData%\Notepad++\userDefineLangs.

EDIT
I am using Notepad++ v7.9.1 x64, and this is a link to the UDL xml which I experienced fontName corruption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
udl Everything related to User Defined Language
Projects
None yet
Development

No branches or pull requests

5 participants