Skip to content

Bug AL Formatter wont save file #8068

Open
@DimosMichal

Description

@DimosMichal

Please include the following with each issue:

1. Describe the bug
When i try to save my edited .al file it doesnt save it (its like formatter running to much time if you press skip (on formatter running) it saves the file ok. Also i get info telling me to post this error here !

[Error - 12:55:42 PM] 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 727
   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

2. To Reproduce

  1. Go to '...'
AL code snippet that demonstrates the issue or a link to a code repository the developers can easily pull down to recreate the issue locally.

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
Save the file with al formatter!

4. Actual behavior
A clear and concise description of what happened accompanied by images, animations, or a link to a video showing the issue occurring

5. Versions:

  • AL Language:
    15.0.1433841
  • Visual Studio Code: 1.101.2
  • Business Central: SAAS 26.3
  • List of Visual Studio Code extensions that you have installed:
  • Operating System:
    • Windows YES
    • Linux
    • MacOS

Final Checklist

Please remember to do the following:

  • Search the issue repository to ensure you are reporting a new issue

  • Reproduce the issue after disabling all extensions except the AL Language extension

  • Simplify your code around the issue to better isolate the problem

Internal work item: AB#591838

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions