What is going on with this user defined language?



  • I have a language definition for AutoHotKey and it’s doing some strange groupings with comments.

    comments.png

    It will also sometimes just randomly change the color of everything in an open document to the green color of a comment. The little boxes that can be clicked to collapse sections of the text will also just randomly jump around as I add or remove lines in the document. The full definition can be seen here: https://pastebin.com/cKYrW5ex



  • @Ksomeone-Msomeone-0 ,

    What version are you using, and what plugins might be interfering (? menu, Debug Info, copy from the dialog and paste in your reply).

    Historically, with large files in a UDL, I have occasionally had random misbehaving of the highlighting or folding in UDL; normally, switching to another tab and back, or restarting Notepad++, is sufficient.

    I have not fully explored it, but I may have evidence that v8.0 has a regression in UDL behavior on at least the code folding – so if you’re using v8.0, you might want to try to download a portable v7.9.5 and see if it behaves better. (I’ll let you know if later today, I am able to find the time to prove it with a simple example; if I can, I will make a bug report.)



  • Notepad++ v7.9.5 (64-bit)
    Build time : Mar 21 2021 - 02:13:17
    Path : D:\program files\Notepad++\notepad++.exe
    Admin mode : OFF
    Local Conf mode : OFF
    OS Name : Windows 10 Pro (64-bit)
    OS Version : 1903
    OS Build : 18362.30
    Current ANSI codepage : 1252
    Plugins : mimeTools.dll NppConverter.dll NppExport.dll

    This problem is not fixed by restarting Npp or switching tabs or anything like that. This problem is persistent from the moment Npp starts with an AHK file open and as previously mentioned, it is completely random on where it places the fold points, sometimes just deciding that the entire open file is one big comment and highlighting it all in comment-green. And it all shifts around as the file is edited with no rhyme or reason that I can see.

    It’s been this way since I first installed the AHK language definition which was only somewhere around 6 months ago, so I don’t have any experience with the definition working properly. No comments on the post on AHK’s forums where this UDL is listed make mention of this particular problem and the author of the UDL has updated it as recently as the 16th of April this year. I don’t know if I’m the only one experiencing this issue, but if so then I don’t understand why. My Npp install is pretty much factory. No customization beyond this single UDL.

    I also downloaded the portable v7.9.5 and the problem exists there, too.

    EDIT: I just noticed that it appears I am on v7.9.5 anyhow. I’ll try updating to v8.0 on the off chance that somehow has an effect.



  • @Ksomeone-Msomeone-0 said in What is going on with this user defined language?:

    EDIT: I just noticed that it appears I am on v7.9.5 anyhow. I’ll try updating to v8.0 on the off chance that somehow has an effect.

    It looks exactly the same in v8.0.



  • It also appears that I didn’t read through the comments on AHK’s forum post thoroughly enough.

    https://www.autohotkey.com/boards/viewtopic.php?f=88&t=50&sid=da6503a94ac7ab3ce3838db359e2f132&start=120#p328091

    It seems this issue has existed for over a year. Their fix of just “clicking on Language->AutoHotKey to temporarily fix it” does not work for me.

    Sorry for the constant replies. Posts can’t be edited after 3 minutes is a bit constraining.



  • @Ksomeone-Msomeone-0 ,

    Since it seems to have been known for some time among AHK users, you might try reading this Forum’s FAQ on making bug reports, and following the instructions you find there. Unfortunately, the User Defined Language system doesn’t get much attention by the Developers, so I don’t give you good odds on that working any better anytime soon.

    Given the popularity of using Notepad++ for editing AHK scripts, it actually surprises me that none of the coding experts in the AHK world have gotten fed up with the limitations of UDL and written a lexer plugin for Notepad++ that handles both the syntax highlighting and code folding inside a plugin DLL instead of relying on the UDL system. You might want to ask in the AHK group whether anyone has done that

    Posts can’t be edited after 3 minutes is a bit constraining.

    That’s done to avoid people going back and editing the post to make a conversation meaningless, or worse, changing the meaning altogether. Example: Original post: “Notepad++ is awesome!”; people upvote and reply saying “I agree completely”; original person goes back and edits to “Notepad++ is horrible”, thus changing the entire meaning. (Personally, I think a better rule would be “cannot edit posts after any reply has been made after that post”. But as far as I know, the NodeBB forum software only allows for timed edit limits rather than reply-count edit limits.)



  • @PeterJones said in What is going on with this user defined language?:

    Given the popularity of using Notepad++ for editing AHK scripts, it actually surprises me that none of the coding experts in the AHK world have gotten fed up with the limitations of UDL and written a lexer plugin for Notepad++ that handles both the syntax highlighting and code folding inside a plugin DLL instead of relying on the UDL system.

    No, but someone went to the effort and made their own SDK instead called AHK Studio. I would prefer not install yet another piece of software for the sole purpose of editing AHK scripts, though. That seems rather redundant, especially since I don’t use AHK for anything major and Npp is universally useful.

    Through my Googling, someone did attempt to make a lexer plugin, but abandoned it before it was complete. That was over 8 years ago and it seems nobody else has tried again that I can find.

    I guess I’m just stuck having to deal with it for now. It’s not a hindrance, but it is a major annoyance. I’ll try to get around to bug reporting this.



  • I often see the same kind of thing with my UDL where the syntax highlighting will become “incorrect”. I notice that it usually happens after I remove a trailing quote of a string or edit a comment character sequence to cause the comment highlighting to change.

    To fix it, I simply save the file and re-load. Unfortunately, this causes the undo history to be lost.



  • @Matt-Borchers, All:

    I too noticed something similar to what you have described. Not only in AutoHotkey but in other UDLs as well. The workaround I use to fix the stray syntax highlighting is to switch to Normal Text Style and then switch back to the UDL. Nothing is lost since there is no need to reload the file. YMMV



  • This post is deleted!


  • There was some discussion of this a few months ago at
    https://community.notepad-plus-plus.org/topic/20755/syntax-highlighting-works-for-a-time-then-irreproducibly-bleeds-only-restarting-npp-fixes-it

    I omitted to add that I may have found that adding a ‘Continue character’ to the ‘Comment line style’ in the UDL dialog, such as ‘/’ may have helped, even though AHK comments don’t actually have a continuation character.

    Since experimenting with these changes I have not noticed the problem of everything highlighted as comments near as much, though it is hard to be sure which changes are doing anything. Adding a space to the end of lines seemed to help a lot.



  • Also with the grouping of comments I found that on the UDL ‘Operators & Delimiters’ tab I had a ‘%’ in the ‘Operators 1’ section and also ‘Open’ ‘%’ ‘Close’ ‘%’ in one of the ‘Delimiter’ sections. Removing the '%'s from the ‘Delimiter’ section fixed some code folding problems I was having.



  • @Ksomeone-Msomeone-0 said in What is going on with this user defined language?:

    I’ll try to get around to bug reporting this.

    It looks like someone did report this as issue#10007 – given the example screenshot, I’m assuming it’s the same person, despite the different username.



  • @PeterJones said in What is going on with this user defined language?:

    @Ksomeone-Msomeone-0 said in What is going on with this user defined language?:

    I’ll try to get around to bug reporting this.

    It looks like someone did report this as issue#10007 – given the example screenshot, I’m assuming it’s the same person, despite the different username.

    That’s mine, yes.


Log in to reply