Page 1 of 2

Code Folding appears to be missing parts of files.

Posted: 16.01.2026 13:32
by sl23
I mostly work with INI file format. I'm not sure if there's a reason for the inconsistency with the Code Folding here, but this is my experience.

It's been like this for years now, I had hoped over time it may be corrected, but I think it gets over looked in favour of other, perhaps more important fixes/requests, etc.

I have the Code Folding column always shown. It shows the plus and minus boxes with lines that connect the current code contained within any given section to the name of that section, all good. But the issue is that it always misses the last line and often misses an entire Section. I have no idea why it always misses the last line of every section, but I have figured out why it misses the whole Section at the end of any given group of Sections.

I am mostly using CT for coding Rainmeter skins. Since the beginning, I have always found it useful to use this as a divider to make section groups easier to locate when scrolling through a file quickly:

Code: Select all

========================================
; SECTION GROUP TITLE
========================================
So for example, it would be used like this:

Code: Select all


[Variables]
Alpha=30
Aqua=0,255,255
AquaDark=#Aqua#,150

etc...

========================================
; STYLES
========================================
[sGlobalText]
FontFace=Trebuchet MS
StringAlign=CenterCenter
StringStyle=Bold
FontSize=9
FontColor=#White#
AntiAlias=1
ClipString=2
DynamicVariables=1
Group=VLC

[sHighlight]
MouseOverAction=[!SetOption #CURRENTSECTION# FontColor "#Green#"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# FontColor ""][!UpdateMeter #CURRENTSECTION#][!Redraw]

========================================
; PROCESSES
========================================
[mProcess]
Measure=Calc
Formula=1
DynamicVariables=1
; Enable Disable System/Drives Bar:
IfCondition=(mProcess2=1) || (mProcess3=1) || (mProcess4=1)
IfTrueAction=[!DeactivateConfig "Barred\SystemBar" "SystemBar2-0.ini"][!DeactivateConfig "Barred\DisksBar" "DrivesBar1.ini"][!Redraw]
IfFalseAction=[!ActivateConfig "Barred\SystemBar" "SystemBar2-0.ini"][!ActivateConfig "Barred\DisksBar" "DrivesBar1.ini"][!Redraw]
; Foobar:
IfCondition3=mProcess1=1
IfTrueAction3=[!EnableMeasureGroup Foobar][!ShowMeterGroup Foobar][!UpdateMeterGroup Foobar][!Redraw]
IfFalseAction3=[!DisableMeasureGroup Foobar][!HideMeterGroup Foobar][!UpdateMeterGroup Foobar][!Redraw]

[mProcess1]
Measure=Process
ProcessName=foobar2000.exe
[mProcess2]
Measure=Process
ProcessName=PotPlayerMini64.exe
[mProcess3]
Measure=Process
ProcessName=VLC.exe
[mProcess4]
etc...

The reason for this is because the 'equals' symbol is highlighted as red. So nowadays, I use CT with the Minimap and Micromap so as to easily see where I am in a file. The Minimap specifically shows the Red/Green/Red quite clearly and gives an excellent way to see the layout more clearly, making navigation so much faster.

The trouble is that using this method causes the Section placed before it to have no Code Folding.

So here, there are two requests:
1. Please could you fix the first issue where the last line of a section is not included in the Code Folding.
2. Is there anything you could do about the second issue where using my method of labelling is affecting Code Folding incorrectly? I would suggest allowing a line that starts with the 'equals' symbol to be used without affecting other things.

Here are some screenshots to show what I mean:
Variables section completely ignored by Code Folding due to the line starting with the 'equals' (=) symbols.
Variables section completely ignored by Code Folding due to the line starting with the 'equals' (=) symbols.
Last lines ignored and last section before line starting with 'equals' (=) symbols
Last lines ignored and last section before line starting with 'equals' (=) symbols
Again, last line of each section and final section in this 'group' are all missing Code Folding.
Again, last line of each section and final section in this 'group' are all missing Code Folding.
Anything you could do would be appreciated, thanks Alexey.

Re: Code Folding appears to be missing parts of files.

Posted: 16.01.2026 14:24
by sl23
I've just noticed it also happens with this code too:

Code: Select all

[Rainmeter]
Update=5000
AccurateText=1
DynamicWindowSize=1

---Measures---

[MeasureParent1]
Measure=WebParser
URL=https://google.com
RegExp=(?siU)^(.{30}).*$
OnUpdateAction=[!UpdateMeasure MeasureChild1][!UpdateMeter *][!Redraw]
DynamicVariables=1

[MeasureChild1]
Measure=WebParser
URL=[MeasureParent1]
StringIndex=1
DynamicVariables=1

[MeasureParent2]
Measure=Plugin
Plugin=FileView
Path="C:\Program Files\Rainmeter"
ShowDotDot=0
ShowFolder=0
Count=3
OnUpdateAction=[!UpdateMeasure MeasureChild2][!UpdateMeter *][!Redraw]
DynamicVariables=1

[MeasureChild2]
Measure=Plugin
Plugin=FileView
Path=[MeasureParent2]
Type=FileName
Index=1
DynamicVariables=1

[mFileParse]
Measure=WebParser
URL=File://#CURRENTPATH#[&mTitle]\[&mApp1].txt
UpdateRate=3600
RegExp=(?siU)Debug=(.*)\nCurrent=(.*)\nRegEx=(.*)\n ...etc... etc...
DynamicVariables=1

---Meters---

[Dummy]
Meter=Image
W=100
H=100
SolidColor=255,0,0,255
DynamicVariables=1

The above code is from another Rainmeter users test skin code.
Notice the same Code Folding missing the last line and the entire section preceding the line starting with a dash.
Notice the same Code Folding missing the last line and the entire section preceding the line starting with a dash.

Re: Code Folding appears to be missing parts of files.

Posted: 16.01.2026 16:52
by main Alexey
Reproduced the problem.
I made fix, file is here
https://github.com/CudaText-addons/CudaText-lexers
code-tree is still broken in Cud: wrong nesting of tree nodes (but it is OK in SynWrite, so Cud's version has a bug, which is very hard to find).

Re: Code Folding appears to be missing parts of files.

Posted: 17.01.2026 14:13
by sl23
Thanks Alexey, but it hasn't made any difference for me. The downloaded file is slightly smaller (19.51KB) than the original (20.24KB) not sure if that makes a difference, something missing maybe?

Other than that, i see no change:
2026-01-17_2.10.06.png
I have downloaded the Rainmeter.lcf and replaced the existing file with the new one:
D:\path\to\CudaText_(x64)_sps\data\lexlib\Rainmeter.lcf
Is that correct? I couldn't see anywhere else that file exists.

I then tried opening a Rainmeter file using the INI lexer and it seems to be ok. But the fix doesn't seem applied to opening INI files using Rainmeter lexer.

Regarding INI lexer Code Folding... It should not fold Where it sees a line starting with = or - as these tend to be used in Rainmeter for defining groups of sections.

I can also confirm the same thing is happening in INF files too. But I use the Rainmeter lexer to open all plain text files: TXT,INI,INF,INC,etc, basically anything that the INI lexer would open, I have set up CT to sue the Rainmeter lexer due to it's more flexible syntax highlighting. So they all appear to work incorrectly wrt Code Folding. But I assume this is related solely to that lexer type?

Thanks. ;)

Re: Code Folding appears to be missing parts of files.

Posted: 17.01.2026 18:01
by main Alexey
I got now the testfile from your post 1 from the top. and confirm - this testfile don't work OK under my lexer. To fix.

Re: Code Folding appears to be missing parts of files.

Posted: 17.01.2026 18:37
by main Alexey
a. I updated the lexer again on Github to support lines beginning with '='.
b. item 'a' is not enough to fix the issue. because Cud's code does decrement of the folding end-point:

Code: Select all

    //fill fold ranges
    if not R.Rule.NotCollapsed then
    begin
      SHint:= UTF8Encode(AnClient.GetCollapsedText(R)); //+'/'+R.Rule.GetNamePath;

      //if after block's end-token we have more tokens on the _same_ line,
      //then decrement block's ending Y (ie exclude that line from folding)
      if BlockHasNextTokensOnSameLine(R.EndIdx, Pnt2.Y) then
      begin
        Dec(Pnt2.Y);
        if Pnt1.Y>=Pnt2.Y then Continue;
        if (SHint<>'') and (SHint[Length(SHint)] in ['}', ')', ']']) then
          SetLength(SHint, Length(SHint)-1);
      end;
it was added for JS/JSON but has side effect on Rainmeter as we see. I need to think here.

Re: Code Folding appears to be missing parts of files.

Posted: 17.01.2026 19:10
by sl23
Ah ok, no problem, perhaps I misunderstood your previous post, I thought it was fixed. Take your time, no rush, I've been using it like this for years now anyway, lol ;)

Re: Code Folding appears to be missing parts of files.

Posted: 19.01.2026 05:45
by main Alexey
fixed now, seems! *.cuda-lexmap file now supports new opt: fold_exclude_line=0 , I will document it in the wiki.

1) get updated Rainmeter lexer again from github
2) get new win64 beta -
https://github.com/Alexey-T/CudaText/di ... t-15535151

something still not ok? post example file.

Re: Code Folding appears to be missing parts of files.

Posted: 19.01.2026 13:15
by sl23
Excellent work, thank you. One minor niggle, you may think it a little picky! Could you please not include lines starting with = or - when folding, Is that possible?
2026-01-19_1.12.01.png

So in this screenshot, if there's a blank line, the folding should stop there as most of them do, unless I have set a header group of sections like this in the screenshot:

Code: Select all


========================================
; CATEGORY FILE VIEW METERS
========================================

Thanks Alexey, really appreciate your work! :D

Re: Code Folding appears to be missing parts of files.

Posted: 19.01.2026 14:48
by main Alexey
thanks! yes, this little tweak is possible. i can make it. small fix in the ini-tree-helper is needed. i will see.