Hello Pierre,
I can suggest implementing different matching modes for the FoldingTaggerBase class. The default mode will work like the current version, assuming the document folding regions are valid - equal number of start and end tags, no crossings between regions. This mode now runs in linear time which is fast (stack iteration). However, to match tags in non-valid document, code will be a bit slower (but will cover cases like yours), because of the need to check all possible end tags (and they are not ordered). So there can be at least 2 modes - 'first' and 'last' match. I am attaching here your modified project with this new API which is in development. So it can be changed over the next weeks. I would appreciate any feedback.
var foldingTagger = new FlexFoldingTagger(this.syntaxEditor) { MatchingAlgorithm = FoldingMatchingAlgorithm.FirstMatch };
Regards,
Petar Mladenov
Progress Telerik
Hi Petar,
Thanks for your answer,
About your question we would say folding from A1 to first A2.
But our original problem (see attached .png) was a bit different, we have :
A1
B2
B1
B2
A2
Where the first B2 is obviously a syntax error as you mentionned. However the first region is folding from A1 to B2 which is not the corresponding closing tag and it's a bit confusing.
We would expect it to close until the A2 tag (END).
The syntax validation feature would also be a nice to have in this situation.
Best regards,
Pierre
Hi Pierre,
To be honest this is logged as a bug but is more like a not supported feature currently. For example in some well-known languages error will be shown in the IDE /Compiler if the structure of the language does not follow the rules. Our SyntaxEditor misses such error / (syntax) validation feature Currently I have a fix candidate code but I am not sure all clients will expect the behavior. For example: Open -close tag couples are A1-A2 and B1-B2. In the following structure:
A1
B1
A2
A2
what do you expect - folding from A1 to first A2 or folding from A1 to second A2. I would appreciate your feedback on the matter. Also, probably property will be a good addition to the FoldingTaggerBase class to cover both scenarios. Having your input in mind, I will raise a discussion in my team and will let you know how we will proceed with this item. Thank you for your understanding.
Regards,
Petar Mladenov
Progress Telerik