UDL - combining C++ folding and Nasal highlighting
-
I have a UDL for Nasal (language used by FlightGear). It works. But there is no folding. If I select C++ as the language I get folding. I want to combine both effects at the same time. I have tried using Define Your Language … multiple times. I have tried specifying {} in both the code 1 and code 2 sections. They never work like folding in C++. C++ folds using {}. Am I tripping over a bug? Is there some way to specify folding in the nasal.xml file that does the highlighting? Am I just not using the dialog correctly? I used the Import function to setup the Nasal language from github (nasal-npp-master maintained by slaiyer).
-
UDL code folding with OPEN =
{
and CLOSE =}
works perfectly, for me:If you cannot replicate my results, you will have to show your User Defined Language dialog on the Folder & Default page, along with code that shows it not working (both in your screenshot, and using the
</>
button and pasting it over thecode_text
that the button inputs)UDL code folding { works fine { nested } }
-
Thank you for your reply. I did some more experimenting and generated a udl from scratch with the gui … and it works. The nasal udl i downloaded appears to have been created 11 years ago. Using it folding doesn’t work. I have examined the definition for it that I found in userDefineLang.xml. It does have Keywords entries for Folders in Code 1 and Folders in Code 2. I have compared the one I created to this one to see if I can see what is different with regards to folding but haven’t found anything. For the time being I will use my manually generated one and ignore the downloaded one. So much for trying to no reinvent the wheel. I will investigate more when I have time. Thanks again.
-
I investigated some more. I found that the Operators 1 was :
- ! ( ) * / % : ? ^ { } ~ + < = > [ ] . , ;
After deleting the {} , it worked. Obviously there is some interaction between the characters in the Operators 1 list and the Folding in Code 1 and 2 styles.
-
Obviously there is some interaction between the characters in the Operators 1 list and the Folding in Code 1 and 2 styles.
The intention for UDL is that no given token (symbol or word) is found in two separate fields: they are supposed to be unique, because you cannot style a token both as an Operator and as a Folding-In-Code, as the two are mutually exclusive. There is an internal order they are processed, but that order is not guaranteed (a few versions back, Notepad++ actually changed the order of a couple of the fields, which broke some UDL that were relying on the old order of processing to handle conflicts in their definitions). If you make the UDL without conflicts, you won’t have problems if Notepad++ changes the internals again.
(By “no given token … is found”, I mean “is found alone”. For example, you could have a fold-open2 of
{
and an operator of{{
– if it finds double-brace, it will render it as an operator, but a single-brace will be a fold-open2.)