Formatter issue with AL Language Extension on save
Please include the following with each issue:
1. Describe the bug Whenever I try to save a file in VS code , The AL Language formatter extension runs indefinitely and the file does not save . On skipping the formatter file saves as normal .
2. To Reproduce Just try to save the file with latest version of AL Language extension .
- Go to '...'
Please report this issue to https://github.com/microsoft/al/issues including information on how to reproduce it, if possible.
Processing of message 'textDocument/formatting' failed with error: 'Index was outside the bounds of the array.'
Details:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Text.StringBuilder.get_Chars(Int32 index)
at Microsoft.Dynamics.Nav.CodeAnalysis.SyntaxDiffer.GetCommonEdgeLengths(StringBuilder oldText, StringBuilder newText, Int32& commonLeadingCount, Int32& commonTrailingCount) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Syntax\SyntaxDiffer.cs:line 747
at Microsoft.Dynamics.Nav.CodeAnalysis.SyntaxDiffer.ReduceChanges(List`1 changeRecords) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Syntax\SyntaxDiffer.cs:line 679
at Microsoft.Dynamics.Nav.CodeAnalysis.SyntaxDiffer.ComputeTextChangesFromOld() in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Syntax\SyntaxDiffer.cs:line 67
at Microsoft.Dynamics.Nav.CodeAnalysis.SyntaxDiffer.GetTextChanges(SyntaxNode oldNode, SyntaxNode newNode) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Syntax\SyntaxDiffer.cs:line 62
at Microsoft.Dynamics.Nav.CodeAnalysis.SyntaxDiffer.GetTextChanges(SyntaxTree before, SyntaxTree after) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Syntax\SyntaxDiffer.cs:line 57
at Microsoft.Dynamics.Nav.CodeAnalysis.Syntax.SyntaxTree.GetChanges(SyntaxTree oldTree) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Syntax\SyntaxTree.cs:line 391
at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Document.GetTextChangesAsync(Document oldDocument, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Workspace\Solution\Document.cs:line 314
at Microsoft.Dynamics.Nav.EditorServices.Protocol.Utility.FormattingHelper.FormatDocument(Document document, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\Utility\FormattingHelper.cs:line 27
at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.FormatDocumentRequestHandler.HandleAsync(DocumentFormattingParams request, Int32 requestId, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\FormatDocumentRequestHandler.cs:line 41
at Microsoft.Dynamics.Nav.EditorServices.Protocol.MessageProtocol.RequestHandlerBase`1.HandleAsync(JToken requestContents, Int32 requestId, CancellationToken cancellationToken) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\MessageProtocol\RequestHandlerBase.cs:line 85
at Microsoft.Dynamics.Nav.EditorServices.Protocol.RequestRegistry.Process(Message message) in X:\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\Endpoints\RequestRegistry.cs:line 84
Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.
3. Expected behavior The file should format and save
4. Actual behavior Formatter keeps on running and file does not save .
5. Versions:
- AL Language:
- Visual Studio Code: 1.99.2(user setup)
- Business Central: 25.5
- List of Visual Studio Code extensions that you have installed: AL CodeActions,Al Language extension, AZ AL Dev tools,(disabled others like gitlens)
- Operating System:
- [x] Windows
- [ ] Linux
- [ ] MacOS
Final Checklist
Please remember to do the following:
-
[x] Search the issue repository to ensure you are reporting a new issue
-
[x] Reproduce the issue after disabling all extensions except the AL Language extension
-
[x] Simplify your code around the issue to better isolate the problem
Internal work item: AB#574561
HI, I've the same problem
Same problem i'm experiencing.
Also having this issue this morning. It usually resolves itself when I reload my VS window but not today. I've tried uninstalling and reinstalling various extensions but it doesn't seem to make a difference.
--EDIT-- I resolved this by switching the AL Extension to Release version and then back to pre-release version
I'm also having this issue. I have narrowed it down to a specific file and code that is causing it. Working fine:
procedure HandleStdServLinesByOrderType(var ServItemLine: Record "Service Item Line"; var StdServCode: Record "Standard Service Code"; var ServHeaderPassed: Record "Service Header")
var
Currency: Record Currency;
ServHeader: Record "Service Header";
ServLine: Record "Service Line";
StdServLine: Record "Standard Service Line";
Factor: Integer;
LastPromptGroup: Integer;
LastPromptConfirmed: Boolean;
ShouldInsert: Boolean;
begin
if StdServCode."Currency Code" <> ServHeader."Currency Code" then
Error(
Text001,
StdServCode.FieldCaption("Currency Code"),
ServHeader.FieldCaption("Currency Code"),
ServHeader.TableCaption);
StdServLine.SetRange("Standard Service Code", StdServCode.Code);
Currency.Initialize(StdServCode."Currency Code");
ServLine."Document Type" := ServItemLine."Document Type";
ServLine."Document No." := ServItemLine."Document No.";
ServLine.SetRange("Document Type", ServItemLine."Document Type");
ServLine.SetRange("Document No.", ServItemLine."Document No.");
if (StdServCode."ASI Remarks" <> '') and (ServHeaderPassed."ASI Remarks" <> StdServCode."ASI Remarks") then
if ServHeader.Get(ServHeaderPassed."Document Type", ServHeaderPassed."No.") then begin
ServHeader."ASI Remarks" := StdServCode."ASI Remarks";
ServHeader."ASI Standard Service Code" := StdServCode.Code;
ServHeader.Modify();
ServHeaderPassed := ServHeader;
end;
if ServHeaderPassed."Prices Including VAT" then
Factor := 1
else
Factor := 0;
case ServHeaderPassed."Service Order Type" of
'OVERHAUL':
StdServLine.SetRange("ASI Overhaul", true);
'BOTTOM END':
StdServLine.SetRange("ASI Bottom End", true);
'INSPECTION':
StdServLine.SetRange("ASI Inspection", true);
'LEAK CHECK':
StdServLine.SetRange("ASI Leak Check", true);
'TIRE CHANG':
StdServLine.SetRange("ASI Tire Change", true);
'TIRE MOUNT':
StdServLine.SetRange("ASI Tire Mount", true);
'TOP END':
StdServLine.SetRange("ASI Top End", true);
'WARRANTY':
StdServLine.SetRange("ASI Warranty", true);
'CAL':
StdServLine.SetRange("ASI Calibration", true);
'RESEAL':
StdServLine.SetRange("ASI Reseal", true);
end;
if not StdServLine.Find('-') then begin
case ServHeaderPassed."Service Order Type" of
'BOTTOM END':
StdServLine.SetRange("ASI Bottom End");
'INSPECTION':
StdServLine.SetRange("ASI Inspection");
'LEAK CHECK':
StdServLine.SetRange("ASI Leak Check");
'TIRE CHANG':
StdServLine.SetRange("ASI Tire Change");
'TIRE MOUNT':
StdServLine.SetRange("ASI Tire Mount");
'TOP END':
StdServLine.SetRange("ASI Top End");
'WARRANTY':
StdServLine.SetRange("ASI Warranty");
'CAL':
StdServLine.SetRange("ASI Calibration");
'RESEAL':
StdServLine.SetRange("ASI Reseal");
end;
StdServLine.SetRange("ASI Overhaul", true);
end;
if StdServLine.FindSet() then begin
repeat
if StdServLine."ASI Step Desc. Code" = 'PREQUOTEINSPECTION' then begin
if ServHeaderPassed."Customer No." <> 'ASI' then begin
ServLine.Init();
ServLine."Line No." := 0;
ServLine.Validate(Type, StdServLine.Type);
if ServHeaderPassed."Link Service to Service Item" then
ServLine.Validate("Service Item Line No.", ServItemLine."Line No.");
if StdServLine.Type = StdServLine.Type::" " then begin
ServLine.Validate("No.", StdServLine."No.");
ServLine.Description := StdServLine.Description
end else
if not StdServLine.EmptyLine() then begin
StdServLine.Testfield("No.");
ServLine.Validate("No.", StdServLine."No.");
if StdServLine."Variant Code" <> '' then
ServLine.Validate("Variant Code", StdServLine."Variant Code");
ServLine.Validate(Quantity, StdServLine.Quantity);
if StdServLine."Unit of Measure Code" <> '' then
ServLine.Validate("Unit of Measure Code", StdServLine."Unit of Measure Code");
ServLine.Description := StdServLine.Description;
if StdServLine.Type = StdServLine.Type::"G/L Account" then
ServLine.Validate(
"Unit Price",
Round(StdServLine."Amount Excl. VAT" *
(ServLine."VAT %" / 100 * Factor + 1), Currency."Unit-Amount Rounding Precision"));
if ServHeaderPassed."ASI Rush Shipment Date" <> 0D then
ServLine.Validate("Needed by Date", ServHeaderPassed."ASI Rush Shipment Date");
if ServLine.Type = ServLine.Type::Item then
if ServLine."Item Category Code" in ['TIRE', 'MAIN ORING', 'STANDARD'] = false then
ServLine."Item Category Code" := 'STANDARD';
end;
ServLine."Shortcut Dimension 1 Code" := StdServLine."Shortcut Dimension 1 Code";
ServLine."Shortcut Dimension 2 Code" := StdServLine."Shortcut Dimension 2 Code";
ServLine."ASI Header" := StdServLine."ASI Header";
ServLine."ASI OrderIndex" := StdServLine."ASI OrderIndex";
ServLine."ASI LineStatus" := StdServLine."ASI LineStatus";
if StdServLine."ASI Resolution Notes".HasValue then begin
StdServLine.CalcFields("ASI Resolution Notes");
ServLine."ASI Resolution Notes" := StdServLine."ASI Resolution Notes";
end;
ServLine."ASI Step Desc. Code" := StdServLine."ASI Step Desc. Code";
CombineDimensions(ServLine, StdServLine);
if StdServLine.InsertLine() then begin
ServLine."Line No." := GetNextLineNo(ServLine);
ServLine.Insert(true);
InsertExtendedText(ServLine);
end;
end;
end else begin
if StdServLine."ASI Step Desc. Code" = 'PIN HEIGHT' then begin
if ServHeaderPassed."ASI Complete Stack" = ServHeaderPassed."ASI Complete Stack"::Yes then begin
ServLine.Init();
ServLine."Line No." := 0;
ServLine.Validate(Type, StdServLine.Type);
if ServHeaderPassed."Link Service to Service Item" then
ServLine.Validate("Service Item Line No.", ServItemLine."Line No.");
if StdServLine.Type = StdServLine.Type::" " then begin
ServLine.Validate("No.", StdServLine."No.");
ServLine.Description := StdServLine.Description
end else
if not StdServLine.EmptyLine() then begin
StdServLine.Testfield("No.");
ServLine.Validate("No.", StdServLine."No.");
if StdServLine."Variant Code" <> '' then
ServLine.Validate("Variant Code", StdServLine."Variant Code");
ServLine.Validate(Quantity, StdServLine.Quantity);
if StdServLine."Unit of Measure Code" <> '' then
ServLine.Validate("Unit of Measure Code", StdServLine."Unit of Measure Code");
ServLine.Description := StdServLine.Description;
if StdServLine.Type = StdServLine.Type::"G/L Account" then
ServLine.Validate(
"Unit Price",
Round(StdServLine."Amount Excl. VAT" *
(ServLine."VAT %" / 100 * Factor + 1), Currency."Unit-Amount Rounding Precision"));
if ServHeaderPassed."ASI Rush Shipment Date" <> 0D then
ServLine.Validate("Needed by Date", ServHeaderPassed."ASI Rush Shipment Date");
if ServLine.Type = ServLine.Type::Item then
if ServLine."Item Category Code" in ['TIRE', 'MAIN ORING', 'STANDARD'] = false then
ServLine."Item Category Code" := 'STANDARD';
end;
ServLine."Shortcut Dimension 1 Code" := StdServLine."Shortcut Dimension 1 Code";
ServLine."Shortcut Dimension 2 Code" := StdServLine."Shortcut Dimension 2 Code";
ServLine."ASI Header" := StdServLine."ASI Header";
ServLine."ASI OrderIndex" := StdServLine."ASI OrderIndex";
ServLine."ASI LineStatus" := StdServLine."ASI LineStatus";
if StdServLine."ASI Resolution Notes".HasValue then begin
StdServLine.CalcFields("ASI Resolution Notes");
ServLine."ASI Resolution Notes" := StdServLine."ASI Resolution Notes";
end;
ServLine."ASI Step Desc. Code" := StdServLine."ASI Step Desc. Code";
CombineDimensions(ServLine, StdServLine);
if StdServLine.InsertLine() then begin
ServLine."Line No." := GetNextLineNo(ServLine);
ServLine.Insert(true);
InsertExtendedText(ServLine);
end;
end;
end else begin
ServLine.Init();
ServLine."Line No." := 0;
ServLine.Validate(Type, StdServLine.Type);
if ServHeaderPassed."Link Service to Service Item" then
ServLine.Validate("Service Item Line No.", ServItemLine."Line No.");
if StdServLine.Type = StdServLine.Type::" " then begin
ServLine.Validate("No.", StdServLine."No.");
ServLine.Description := StdServLine.Description
end else
if not StdServLine.EmptyLine() then begin
StdServLine.Testfield("No.");
ServLine.Validate("No.", StdServLine."No.");
if StdServLine."Variant Code" <> '' then
ServLine.Validate("Variant Code", StdServLine."Variant Code");
ServLine.Validate(Quantity, StdServLine.Quantity);
if StdServLine."Unit of Measure Code" <> '' then
ServLine.Validate("Unit of Measure Code", StdServLine."Unit of Measure Code");
ServLine.Description := StdServLine.Description;
if StdServLine.Type = StdServLine.Type::"G/L Account" then
ServLine.Validate(
"Unit Price",
Round(StdServLine."Amount Excl. VAT" *
(ServLine."VAT %" / 100 * Factor + 1), Currency."Unit-Amount Rounding Precision"));
if ServHeaderPassed."ASI Rush Shipment Date" <> 0D then
ServLine.Validate("Needed by Date", ServHeaderPassed."ASI Rush Shipment Date");
if ServLine.Type = ServLine.Type::Item then
if ServLine."Item Category Code" in ['TIRE', 'MAIN ORING', 'STANDARD'] = false then
ServLine."Item Category Code" := 'STANDARD';
end;
ServLine."Shortcut Dimension 1 Code" := StdServLine."Shortcut Dimension 1 Code";
ServLine."Shortcut Dimension 2 Code" := StdServLine."Shortcut Dimension 2 Code";
ServLine."ASI Header" := StdServLine."ASI Header";
ServLine."ASI OrderIndex" := StdServLine."ASI OrderIndex";
ServLine."ASI LineStatus" := StdServLine."ASI LineStatus";
if StdServLine."ASI Resolution Notes".HasValue then begin
StdServLine.CalcFields("ASI Resolution Notes");
ServLine."ASI Resolution Notes" := StdServLine."ASI Resolution Notes";
end;
ServLine."ASI Step Desc. Code" := StdServLine."ASI Step Desc. Code";
CombineDimensions(ServLine, StdServLine);
if StdServLine.InsertLine() then begin
ServLine."Line No." := GetNextLineNo(ServLine);
ServLine.Insert(true);
InsertExtendedText(ServLine);
end;
end;
end;
until StdServLine.Next() = 0;
end;
end;
This breaks it:
procedure HandleStdServLinesByOrderType(var ServItemLine: Record "Service Item Line"; var StdServCode: Record "Standard Service Code"; var ServHeaderPassed: Record "Service Header")
var
Currency: Record Currency;
ServHeader: Record "Service Header";
ServLine: Record "Service Line";
StdServLine: Record "Standard Service Line";
Factor: Integer;
LastPromptGroup: Integer;
LastPromptConfirmed: Boolean;
ShouldInsert: Boolean;
begin
if StdServCode."Currency Code" <> ServHeader."Currency Code" then
Error(
Text001,
StdServCode.FieldCaption("Currency Code"),
ServHeader.FieldCaption("Currency Code"),
ServHeader.TableCaption);
StdServLine.SetRange("Standard Service Code", StdServCode.Code);
Currency.Initialize(StdServCode."Currency Code");
ServLine."Document Type" := ServItemLine."Document Type";
ServLine."Document No." := ServItemLine."Document No.";
ServLine.SetRange("Document Type", ServItemLine."Document Type");
ServLine.SetRange("Document No.", ServItemLine."Document No.");
if (StdServCode."ASI Remarks" <> '') and (ServHeaderPassed."ASI Remarks" <> StdServCode."ASI Remarks") then
if ServHeader.Get(ServHeaderPassed."Document Type", ServHeaderPassed."No.") then begin
ServHeader."ASI Remarks" := StdServCode."ASI Remarks";
ServHeader."ASI Standard Service Code" := StdServCode.Code;
ServHeader.Modify();
ServHeaderPassed := ServHeader;
end;
if ServHeaderPassed."Prices Including VAT" then
Factor := 1
else
Factor := 0;
case ServHeaderPassed."Service Order Type" of
'OVERHAUL':
StdServLine.SetRange("ASI Overhaul", true);
'BOTTOM END':
StdServLine.SetRange("ASI Bottom End", true);
'INSPECTION':
StdServLine.SetRange("ASI Inspection", true);
'LEAK CHECK':
StdServLine.SetRange("ASI Leak Check", true);
'TIRE CHANG':
StdServLine.SetRange("ASI Tire Change", true);
'TIRE MOUNT':
StdServLine.SetRange("ASI Tire Mount", true);
'TOP END':
StdServLine.SetRange("ASI Top End", true);
'WARRANTY':
StdServLine.SetRange("ASI Warranty", true);
'CAL':
StdServLine.SetRange("ASI Calibration", true);
'RESEAL':
StdServLine.SetRange("ASI Reseal", true);
end;
if not StdServLine.Find('-') then begin
case ServHeaderPassed."Service Order Type" of
'BOTTOM END':
StdServLine.SetRange("ASI Bottom End");
'INSPECTION':
StdServLine.SetRange("ASI Inspection");
'LEAK CHECK':
StdServLine.SetRange("ASI Leak Check");
'TIRE CHANG':
StdServLine.SetRange("ASI Tire Change");
'TIRE MOUNT':
StdServLine.SetRange("ASI Tire Mount");
'TOP END':
StdServLine.SetRange("ASI Top End");
'WARRANTY':
StdServLine.SetRange("ASI Warranty");
'CAL':
StdServLine.SetRange("ASI Calibration");
'RESEAL':
StdServLine.SetRange("ASI Reseal");
end;
StdServLine.SetRange("ASI Overhaul", true);
end;
if StdServLine.FindSet() then begin
repeat
ShouldInsert := true;
if StdServLine."ASI Prompt" and ((StdServLine."ASI Prompt Group" = 0) or (StdServLine."ASI Prompt Group" = LastPromptGroup)) then begin
if StdServLine.Type = StdServLine.Type::Resource then begin
// Should indicate that this is the first line of a potential group
if StdServLine."ASI Prompt Verbiage" > '' then begin
if StdServLine."ASI Prompt Group" > 0 then
if LastPromptGroup = 0 then
LastPromptGroup := StdServLine."ASI Prompt Group";
LastPromptConfirmed := Confirm(StdServLine."ASI Prompt Verbiage", true);
if not LastPromptConfirmed then
ShouldInsert := false;
end else begin
// Should indicate that this is additional line of group
if not LastPromptConfirmed then
ShouldInsert := false;
end;
end else begin
// Always clear this if prompt is false to ensure leftover variables get cleared
Clear(LastPromptGroup);
Clear(LastPromptConfirmed);
end;
end else begin
end;
if ShouldInsert then
if StdServLine."ASI Step Desc. Code" = 'PREQUOTEINSPECTION' then begin
if ServHeaderPassed."Customer No." <> 'ASI' then begin
ServLine.Init();
ServLine."Line No." := 0;
ServLine.Validate(Type, StdServLine.Type);
if ServHeaderPassed."Link Service to Service Item" then
ServLine.Validate("Service Item Line No.", ServItemLine."Line No.");
if StdServLine.Type = StdServLine.Type::" " then begin
ServLine.Validate("No.", StdServLine."No.");
ServLine.Description := StdServLine.Description
end else
if not StdServLine.EmptyLine() then begin
StdServLine.Testfield("No.");
ServLine.Validate("No.", StdServLine."No.");
if StdServLine."Variant Code" <> '' then
ServLine.Validate("Variant Code", StdServLine."Variant Code");
ServLine.Validate(Quantity, StdServLine.Quantity);
if StdServLine."Unit of Measure Code" <> '' then
ServLine.Validate("Unit of Measure Code", StdServLine."Unit of Measure Code");
ServLine.Description := StdServLine.Description;
if StdServLine.Type = StdServLine.Type::"G/L Account" then
ServLine.Validate(
"Unit Price",
Round(StdServLine."Amount Excl. VAT" *
(ServLine."VAT %" / 100 * Factor + 1), Currency."Unit-Amount Rounding Precision"));
if ServHeaderPassed."ASI Rush Shipment Date" <> 0D then
ServLine.Validate("Needed by Date", ServHeaderPassed."ASI Rush Shipment Date");
if ServLine.Type = ServLine.Type::Item then
if ServLine."Item Category Code" in ['TIRE', 'MAIN ORING', 'STANDARD'] = false then
ServLine."Item Category Code" := 'STANDARD';
end;
ServLine."Shortcut Dimension 1 Code" := StdServLine."Shortcut Dimension 1 Code";
ServLine."Shortcut Dimension 2 Code" := StdServLine."Shortcut Dimension 2 Code";
ServLine."ASI Header" := StdServLine."ASI Header";
ServLine."ASI OrderIndex" := StdServLine."ASI OrderIndex";
ServLine."ASI LineStatus" := StdServLine."ASI LineStatus";
if StdServLine."ASI Resolution Notes".HasValue then begin
StdServLine.CalcFields("ASI Resolution Notes");
ServLine."ASI Resolution Notes" := StdServLine."ASI Resolution Notes";
end;
ServLine."ASI Step Desc. Code" := StdServLine."ASI Step Desc. Code";
CombineDimensions(ServLine, StdServLine);
if StdServLine.InsertLine() then begin
ServLine."Line No." := GetNextLineNo(ServLine);
ServLine.Insert(true);
InsertExtendedText(ServLine);
end;
end;
end else begin
if StdServLine."ASI Step Desc. Code" = 'PIN HEIGHT' then begin
if ServHeaderPassed."ASI Complete Stack" = ServHeaderPassed."ASI Complete Stack"::Yes then begin
ServLine.Init();
ServLine."Line No." := 0;
ServLine.Validate(Type, StdServLine.Type);
if ServHeaderPassed."Link Service to Service Item" then
ServLine.Validate("Service Item Line No.", ServItemLine."Line No.");
if StdServLine.Type = StdServLine.Type::" " then begin
ServLine.Validate("No.", StdServLine."No.");
ServLine.Description := StdServLine.Description
end else
if not StdServLine.EmptyLine() then begin
StdServLine.Testfield("No.");
ServLine.Validate("No.", StdServLine."No.");
if StdServLine."Variant Code" <> '' then
ServLine.Validate("Variant Code", StdServLine."Variant Code");
ServLine.Validate(Quantity, StdServLine.Quantity);
if StdServLine."Unit of Measure Code" <> '' then
ServLine.Validate("Unit of Measure Code", StdServLine."Unit of Measure Code");
ServLine.Description := StdServLine.Description;
if StdServLine.Type = StdServLine.Type::"G/L Account" then
ServLine.Validate(
"Unit Price",
Round(StdServLine."Amount Excl. VAT" *
(ServLine."VAT %" / 100 * Factor + 1), Currency."Unit-Amount Rounding Precision"));
if ServHeaderPassed."ASI Rush Shipment Date" <> 0D then
ServLine.Validate("Needed by Date", ServHeaderPassed."ASI Rush Shipment Date");
if ServLine.Type = ServLine.Type::Item then
if ServLine."Item Category Code" in ['TIRE', 'MAIN ORING', 'STANDARD'] = false then
ServLine."Item Category Code" := 'STANDARD';
end;
ServLine."Shortcut Dimension 1 Code" := StdServLine."Shortcut Dimension 1 Code";
ServLine."Shortcut Dimension 2 Code" := StdServLine."Shortcut Dimension 2 Code";
ServLine."ASI Header" := StdServLine."ASI Header";
ServLine."ASI OrderIndex" := StdServLine."ASI OrderIndex";
ServLine."ASI LineStatus" := StdServLine."ASI LineStatus";
if StdServLine."ASI Resolution Notes".HasValue then begin
StdServLine.CalcFields("ASI Resolution Notes");
ServLine."ASI Resolution Notes" := StdServLine."ASI Resolution Notes";
end;
ServLine."ASI Step Desc. Code" := StdServLine."ASI Step Desc. Code";
CombineDimensions(ServLine, StdServLine);
if StdServLine.InsertLine() then begin
ServLine."Line No." := GetNextLineNo(ServLine);
ServLine.Insert(true);
InsertExtendedText(ServLine);
end;
end;
end else begin
ServLine.Init();
ServLine."Line No." := 0;
ServLine.Validate(Type, StdServLine.Type);
if ServHeaderPassed."Link Service to Service Item" then
ServLine.Validate("Service Item Line No.", ServItemLine."Line No.");
if StdServLine.Type = StdServLine.Type::" " then begin
ServLine.Validate("No.", StdServLine."No.");
ServLine.Description := StdServLine.Description
end else
if not StdServLine.EmptyLine() then begin
StdServLine.Testfield("No.");
ServLine.Validate("No.", StdServLine."No.");
if StdServLine."Variant Code" <> '' then
ServLine.Validate("Variant Code", StdServLine."Variant Code");
ServLine.Validate(Quantity, StdServLine.Quantity);
if StdServLine."Unit of Measure Code" <> '' then
ServLine.Validate("Unit of Measure Code", StdServLine."Unit of Measure Code");
ServLine.Description := StdServLine.Description;
if StdServLine.Type = StdServLine.Type::"G/L Account" then
ServLine.Validate(
"Unit Price",
Round(StdServLine."Amount Excl. VAT" *
(ServLine."VAT %" / 100 * Factor + 1), Currency."Unit-Amount Rounding Precision"));
if ServHeaderPassed."ASI Rush Shipment Date" <> 0D then
ServLine.Validate("Needed by Date", ServHeaderPassed."ASI Rush Shipment Date");
if ServLine.Type = ServLine.Type::Item then
if ServLine."Item Category Code" in ['TIRE', 'MAIN ORING', 'STANDARD'] = false then
ServLine."Item Category Code" := 'STANDARD';
end;
ServLine."Shortcut Dimension 1 Code" := StdServLine."Shortcut Dimension 1 Code";
ServLine."Shortcut Dimension 2 Code" := StdServLine."Shortcut Dimension 2 Code";
ServLine."ASI Header" := StdServLine."ASI Header";
ServLine."ASI OrderIndex" := StdServLine."ASI OrderIndex";
ServLine."ASI LineStatus" := StdServLine."ASI LineStatus";
if StdServLine."ASI Resolution Notes".HasValue then begin
StdServLine.CalcFields("ASI Resolution Notes");
ServLine."ASI Resolution Notes" := StdServLine."ASI Resolution Notes";
end;
ServLine."ASI Step Desc. Code" := StdServLine."ASI Step Desc. Code";
CombineDimensions(ServLine, StdServLine);
if StdServLine.InsertLine() then begin
ServLine."Line No." := GetNextLineNo(ServLine);
ServLine.Insert(true);
InsertExtendedText(ServLine);
end;
end;
end;
until StdServLine.Next() = 0;
end;
end;
--EDIT-- Once I resolve the actual formatting issues (tab lines where they should be) it saves fine.
In particularly: Broken -
Fixed - (it will finish formatting the other parts if the highlighted area is resolved correctly before saving)
I solved this issue by switching to a Pre-release version of the "AL Language extension for Microsoft Dynamics 365 Business Central" and then switching back to a normal version.
Hope this will help other people too with the same problem.
@aaryan-sarawgi1 I am not able to reproduce the issue (neither with older versions nor with the newest pre-release). Could you please check if the issue still occurs with the newest pre-release, and if so, share a minimal example and detailed repro steps with us?
@krupybalu Yes, issue still persist especially on objects that are large (1500+ lines)
@Haxiboy Thank you for the confirmation! Any chance you can provide us with an example to trigger the issue? After multiple attempts we have not been able to reproduce the issue.
@Haxiboy Thank you for the confirmation! Any chance you can provide us with an example to trigger the issue? After multiple attempts we have not been able to reproduce the issue.
Open base app for example codeunit 80, make some edits and try to save it. After a couple of edits, saving the al file will hang on formatting, sometimes formatter fails to work properly and destroying the structure / order of code. If you Edit on multiple places the issue is easier to replicate.
@Haxiboy Much appreciated! I'll give it a try.
Unfortunately, we've been unable to reproduce this issue with the current information.
Closing for now due to insufficient reproduction information. If the problem persists with the newest pre-release, please open a new issue and make sure to include the following details to help us investigate:
- Minimal, self-contained al project that reproduces the issue
- Tested in clean VS Code + AL Language extension only (no other extensions)
- Exact steps to reproduce the issue
- Environment details