anzwdev / al-code-outline

AL Code Outline for Visual Studio Code
MIT License
51 stars 13 forks source link

Command Remove Unused Variables from Active Editor incorrectly removes adjacent preprocessor directive #574

Closed ernestasjuska closed 3 months ago

ernestasjuska commented 4 months ago

Hi,

Command Remove Unused Variables from Active Editor incorrectly removes adjacent preprocessor directive.

Before:

codeunit 50037 "GEL Demo"
{
#pragma warning disable LC0010
    trigger OnRun()
#pragma warning restore LC0010
    var
        UnitedVATInvoice: Integer;
    begin
        // some code
    end;
}

After:

codeunit 50037 "GEL Demo"
{
#pragma warning disable LC0010
    trigger OnRun()
    begin
        // some code
    end;
}

It should not touch pragma directive and only remove the variable.

codeunit 50037 "GEL Demo"
{
#pragma warning disable LC0010
    trigger OnRun()
#pragma warning restore LC0010
    begin
        // some code
    end;
}

Thanks.

P.S. It would be nice to have some mechanism to detect when the code-altering command does something other than its direct purpose - e.g. show warning, message or list with places to double check. E.g. in this case it was supposed to only remove variables, but it also removed preprocessor directives that are not part of particular variable declaration.

anzwdev commented 3 months ago

Thank you for reporting the issue, it has been fixed in the last release.