XeroByte wrote:I can't think why you're having this issue. Could you please try run the function on a .ahk file that only has a few test functions and see if it can index them?

It works now with the following simple file including both labels and functions. Not sure what I was doing wrong before. But it still fail to index functions in my larger "real-life" script (15 K lines).

JnLlnd wrote:I will insert debugging code in your script and try to see if I can find what is happening.

If it's a RegEx issue (which it sounds like it may be) then I'm not sure that debugging code will help. I guess you probably don't want to send me your real-life script with all its 15K lines - but if you did I could look into it.

Alternatively - if you just sent me (or posted here) your script from the first line until the end of the first function that appears in your script then that may be enough to work with.

The main problem I found is that in your file the lines all end in just the LF character rather than CR + LF. This interferes with the 'beginning' and 'end' of lines detection by the RegEx.
As soon as I converted the file to Windows CR LF (using notepad++ Edit > EOL Conversion > Windows Format) then this issue disappears. It may be possible to account for this in the RegEx, but I probably won't because I don't believe that it is normal for AHK code to be written without the windows CR LF end of lines.

The other issue I can see is (something I should probably fix) - labels are being identified - but they're not actually supposed to be labels since they are inside /* */ comment blocks.

Let me know how you go with this, and if you're OK with converting your AHK to the Windows CRLF end of line.

My apologies - looks like I jumped to the wrong conclusion there. I got a bit excited when I saw just the LF, so i didn't investigate any further. I've inspected it a bit closer now and realised that it was exactly as you said - no functions were appearing in the api file, only labels.

A little digging showed the RegEx is producing a -21 error which I have never seen before. Apparently this means "Recursion too deep"... I need to dig a little deeper into this but the AHK docs say to modify the pattern to be more restrictive. I'll put a bit of work into that and see if i can get it working on your file.

For the moment I believe this error will only trigger on large files like yours.

I've attempted to tackle this issue a few times now but couldn't come up a reasonable solution. I think this will take a near complete rewrite (probably involving splitting up the different coding styles and dealing with them individually).