3

So I've made a user defined language in Notepad++ to organize a writing project. I know how to do code-folding, and for the past several months it has worked well. The problem is that recently, the code-folding function is several lines off from the actual positions of the open and close markers. E.g.:

01
02
03 { the sea of time
04 some
05 events
06 that 
07 are 
08 happening 
09 }
10
11

The { and } are used to open and close a folded block. But the actual functioning makes the open and close buttons in the Notepad++ UI appear perhaps at lines 01 and 10, or lines 01 and 11. So when I go to fold the block, it folds more than just the section I have enclosed, even eclipsing the beginning of the next block, and in some cases preventing me from opening the block again without disabling the language file. If I go and enter a couple blank lines right before the close marker, it resets to how it should be, but then breaks again if I actually fold any of the blocks or if I switch into another document in Notepad++.

I have not been able to find any documentation elsewhere on this error. The text file I'm writing is several hundred kilobytes, about 2000 lines long, and the associated language file has over 1500 defined keywords. Is this just a case of Notepad++ not being able to process this much formatting?

The other possible source of the problem is that several days ago I briefly checked and then unchecked the "Fold compact (fold empty lines)" checkbox on the Folders page of the User Defined Language dialog, to see what it would do, because I could not find documentation on what it does. That was about when the problem started - but the checkbox has been unchecked since then, and the error persists.

  • Well, if it worked before, to solve your problem, what about uninstall n++ and install it again and install your language – Jorge Campos Sep 23 '15 at 20:27
  • ...or downgrade N++ to older version where it worked. – miroxlav Sep 23 '15 at 21:23
  • What I did first was export the language, removed it from n++, and then reimported it, which did not solve the problem, and now it's not in the user defined languages list. So I'll try these options. EDIT: I hadn't updated n++ between then and now, so I don't think a downgrade would change anything. I just updated it to the most recent version instead, problem was not solved, so I'm on my way to uninstall completely. – undine_centimeter Sep 24 '15 at 01:08
  • Nope, still doesn't work. Uninstalled, reinstalled, fold markers are still misaligned. An earlier version of the user defined language also does not function properly when it is applied, and its XML data is almost ten times smaller. I'm using a custom extension, if that makes a difference. – undine_centimeter Sep 24 '15 at 01:20
  • 1
    I had the same problem, try EOL conversion under Edit, and choose Windows, cleared it up for me – Michael Russo Nov 23 '16 at 14:29
  • I had the same problem and didn't want to change from LF to CRLF as I was editing a file that is natively LF only. I found the only way to fix this was to remove everything from the "Operations & Delimiters" section. I initially only removed the only fold characters used { and } which fixed a small portion but I noticed it as screwed up by text and then other items, once O&D was cleared the folding was 100% correct through the entire document. Seems Notepad ++ has issues doing both folding and O&D Highlighting – Ben Personick May 27 '18 at 15:10

1 Answers1

2

If you have any Delimiters or Operators defined, this can cause code folding to offset.

The error only seems to exist when both the open and close of the delimiter appear on the same line. In my UDL I defined ".sig" as my open delimiter and "nal" as my close in order to highlight ".signal". For every use of ".signal" in my code, my code folding was shifted down by 1 line from the close which caused my folding to become a hindrance instead of a help.

In a slightly related matter, if you want to highlight ".signal" or something similar, this can be accomplished by making "." your Operator 1 and "signal" your Operator 2.

Spartacus
  • 133
  • 1
  • 6