Forum > General
Adding a new event corrupts use of Regions
(1/1)
oopman:
If you use {$region} and {$endregion] to encapsulate your code. Then if you add a new event, Lazarus inserts the new code before the {$endregion} which screws up the folding.
{$region TForm1. SomeFunction}
procedure TForm1.SomeFunction}
begin
end ;
<<- If you add a new event it gets stuck in here instead of after the endregion statement?
{$endregion}
howardpc:
CodeTools has several shortcomings. You have found one of them.
I'm sure a patch to improve this behaviour would be accepted.
Martin_fr:
Tricky....
How can the IDE know if your "$region" is meant for just one method, or maybe all methods of a class? Or even some subset of the methods that you choose by some criteria? (I sometimes group 3 or 4 methods together).
Sorry, I am not aware of any setting to change this.
You could move the ";" from the "end;" to after the "endregion",
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---end{$endregion} ;
Btw, I guess (not tested) that IFDEF may have similar issues.
-----------------
I don't know if the following has any chance at ever being done, or accepted as desirable feature.
There would need to be some setting, if a comment/directive should be attributed to the procedure body in front of it.
Maybe $endregion and $endif should be.... (and I guess that has a chance to be accepted)
Maybe spacing (empty lines) could be checked (e.g. for comments)... but not sure that is the best idea.
PascalDragon:
--- Quote from: Martin_fr on May 11, 2022, 11:49:28 pm ---How can the IDE know if your "$region" is meant for just one method, or maybe all methods of a class? Or even some subset of the methods that you choose by some criteria? (I sometimes group 3 or 4 methods together).
--- End quote ---
Maybe use a rather simple approach: don't add them automatically into a region (if the user wants them there they can move it). If it already is in a region then keep it there when updating something.
oopman:
Maybe I've missed it but I think the IDE adds a new event where it decides to and not where the cursor is? But I maybe wrong on this.
When you double-click on say an OnExit event to create an event, the IDE decides where to add the event code into the source file. I always have to cut the new event and paste it outside the $region.
Navigation
[0] Message Index