editor.getFoldLevel(line) not returning correct header flag when it's outside screen view
I have a script that detects all lines in a document that contain a configurable string (eg: "collapse") and collapses those lines (they need to be collapsable).
After noticing it doesn't work as expected sometimes, I went debug it. I found that "editor.getFoldLevel(line)" is returning 9218 for the first two lines that contain the string, and 1024 for all the others. Those two first lines are the only lines that are visible at startup, when the script is executed (though the second string is not visible at start, but it is after the first string is collapsed). All "collapse" strings are placed in lines with a [-] box.
This makes me think editor.getFoldLevel(line) returns header flag 0 even if it is a fold point, when it is outside screen view.
@Benur21 See also https://scintilla.sourceforge.io/Lexer.txt at the section: Special case: Folding
- For which file type do you use the script. The output seems to depend on the lexer used.
- Do you have same sample code to reproduce the issue.
The type of file I'm using the script on is HTML, for example https://hastebin.com/abugipagaz.xml The python code I'm using is this https://hastebin.com/erufoxotiq.py, and it is appended to startup.py, so it runs at start. And in Configurations, Initialisation is ATSTARTUP instead of LAZY.
Notepad++ v7.5.9 (32-bit) Python Script v1.3
By the way, from my tests, it seems to work correctly after the line showed in the screen, even if it's not visible anymore when re-running the script.
PS: The output on the console from the code above when I open the html files and click the text (also interesting that it needs to be clicked or scrolled in order for the startup script to run) is:
---------- CONST FOLDLEVEL.HEADERFLAG = 8192
editor.getFoldLevel(46) = 1024
editor.getFoldLevel(46) & FOLDLEVEL.HEADERFLAG = 0
From-To: []