al-code-outline icon indicating copy to clipboard operation
al-code-outline copied to clipboard

[Bug] 'Sort Triggers' with sortSingleNodeRegions

Open fvet opened this issue 1 year ago • 0 comments

As requested in #535 we would like to sort triggers only (not procedures).

I tried to run the 'Sort Triggers' actions, but nothing happens, since the triggers are surrounded by regions.

I've tested by setting alOutline.sortSingleNodeRegions to true, but this has a annoying side effect: several procedures (inside nested regions) are removed.

Example:

Code before running the 'Sort Triggers' action:

// Release

    #region Release
    internal procedure Release(var TptTrip: Record "ESCD Tpt Trip")
    begin
        if TptTrip.Status = TptTrip.Status::Released then
            exit;

        OnBeforeRelease(TptTrip);

        TptTrip.TestField(Status, TptTrip.Status::Open);

        CheckOpenWhseDocuments(TptTrip);
        CheckCapacity(TptTrip);

        TptTrip.Status := TptTrip.Status::Released;
        TptTrip.Modify();

        OnAfterRelease(TptTrip);
    end;

    #region OnBeforeRelease
    [IntegrationEvent(false, false)]
    local procedure OnBeforeRelease(var TptTrip: Record "ESCD Tpt Trip")
    begin
    end;
    #endregion OnBeforeRelease

    #region OnAfterRelease
    [IntegrationEvent(false, false)]
    local procedure OnAfterRelease(var TptTrip: Record "ESCD Tpt Trip")
    begin
    end;
    #endregion OnAfterRelease
    #endregion Release

Code after running the action

// Release

    #region Release
    internal procedure Release(var TptTrip: Record "ESCD Tpt Trip")
    begin
        if TptTrip.Status = TptTrip.Status::Released then
            exit;

        OnBeforeRelease(TptTrip);

        TptTrip.TestField(Status, TptTrip.Status::Open);

        CheckOpenWhseDocuments(TptTrip);
        CheckCapacity(TptTrip);

        TptTrip.Status := TptTrip.Status::Released;
        TptTrip.Modify();

        OnAfterRelease(TptTrip);
    end;
    #endregion Release

As you notice, the main procedure (Release) is surrounded by a region, similar for the event publishers which are surrounded as well (although one nested inside another region)

After running the 'Sort triggers' action, the event publishers are removed.

Request behavior I would have expected these regions not to be touched when calling 'Sort triggers', as the related code contains procedures only, no triggers.

[ ] In addition, the alOutline.sortMembersGlobalVariablesSortMode (default to AfterTriggers) seems not to be applied when using alOutline.sortSingleNodeRegions to true.

fvet avatar Aug 06 '24 19:08 fvet