undine_centimeter
undine_centimeter

Reputation: 141

Notepad++ Code Folding Opens and Closes are mispositioned by several lines

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.

Upvotes: 4

Views: 2850

Answers (1)

Spartacus
Spartacus

Reputation: 165

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.

Upvotes: 3

Related Questions