ScintillaOrg / lexilla

A library of language lexers for use with Scintilla
https://www.scintilla.org/Lexilla.html
Other
179 stars 64 forks source link

Fold issue in verilog with nested MACRO and nested if #212

Closed ramamk closed 10 months ago

ramamk commented 10 months ago

https://github.com/ScintillaOrg/lexilla/issues/204#issuecomment-1713670275

Hi Team, Found one more issue regarding same fold issue :( .

line number 7 fold should end at 12 but it is ending at 16. ifdef at 14 fold is closing with normal end keyword at 15 which should close with endif at 16 only. begin fold line number 11 is closing with endif line 12 which should close only with end at line 15.

image

nyamatongwe commented 10 months ago

The behaviour appears to be in accordance with the design.

Folding is based strictly on fold level which increments for fold start points "(", "begin", "`ifdef" and decrements for fold end points ")", "end", "`endif". There is no matching of fold feature types, so keyword "begin" may match pre-processor "`endif".

If you want folding to match feature types then you should describe in detail the mechanics of how that would work, particularly with overlapping ranges such as in this example.

ramamk commented 10 months ago

if it encounters a fold end point if it matches to fold start point then it should decrement so that it wont create issue, if it decrements to any fold end point for a fold start point it will be an issue i guess, i know it is complicated to implement just letting know the problem.

nyamatongwe commented 10 months ago

if it encounters a fold end point if it matches to fold start point then it should decrement so that it wont create issue, if it decrements to any fold end point for a fold start point it will be an issue i guess

If you decrement on only matching ends then you will see an elevated level for the rest of the file so folding a previous start will fold the rest of the file.

i know it is complicated to implement just letting know the problem

It appears to me unworkable which is why folding does not differentiate between fold point types. You could try to implement your desired behaviour in your application, possibly as a script.

Since I cannot see a way to reasonably constrain folds to matching types, I do not consider this a bug. Its just how folding works for Scintilla and Lexilla. So I am marking this issue as 'invalid' and will close it.