Closed achim-t closed 1 year ago
Hi Achim,
I assume that this does not apply to all procedure extractions. In some scenarios you would maybe want to have that procedure inside your region, that's why I don't want to change the default behaviour.
So let's think about a different solution. What you could do by now already is, that you set the setting
"alCodeActions.findNewProcedureLocation": "Always ask"
With that you get a question where you want to place the procedure exactly.
I use it myself also often, but I thought as well that a setting might be too strict. Because sometimes I want to have it placed just to the other local procedures (without further asking me) and sometimes I want that it is placed at a specific position. So maybe a second code action would then be great. What do you think?
Hi David.
The region could be viewed as part of the procedure (or trigger etc.) if they have the same name. That way the anchor can be found (almost) like before, and the function can be placed inside or outside of regions. Assuming we want to extract the message call:
{
//#region DoSomething
procedure DoSomething()
begin
Message('hello world');
end;
//#endregion DoSomething
//<- PLACE HERE
}
{
//#region local procedures
procedure DoSomething()
begin
Message('hello world');
end;
//<- PLACE HERE
//#endregion local procedures
}
{
//#region local procedures
//#region DoSomething
procedure DoSomething()
begin
Message('hello world');
end;
//#endregion DoSomething
//<- PLACE HERE
//#endregion local procedures
}
I don't like the alwaysAsk option and would prefer a second code action if the above can't be achieved.
Okay, that's something different. I think that's something we can all work with. I'm working on it.
Version is released. I hope it is how you want it to have. Otherwise feel free to reopen this issue :)
Thanks, this works great (as soon as I use #region
instead of //#region
).
Extracting the message:
I would have expected the new procedure to be located after the region.