DavidFeldhoff / al-codeactions

MIT License
17 stars 8 forks source link

Illegal argument: character must be non-negative #52

Closed wbrakowski closed 4 years ago

wbrakowski commented 4 years ago

Hi David,

today I encountered a puzzling error message when trying to create the procedure "RunReportModal":

"Illegal argument: character must be non-negative"

image

Do you know what is going on there? This message even stayed there when I changed the procedure name.

image

DavidFeldhoff commented 4 years ago

Hi Waldemar, thanks for reporting. Honestly I have no clue what is going on there. I couldn't reproduce it neither.. Does it disappear if you switch documents back and forth and try it again? And do I get it right that you can't create the procedure "CreateThis"? Does it appear more often today (yesterday was an update) or did you do something special which would help me reproducing it?

DavidFeldhoff commented 4 years ago

Is maybe anything displayed in the "Output" -> "Log (Extension Host)" ?

wbrakowski commented 4 years ago

The problem stays when I switch documents and even when I restart Visual Studio Code. Is there a chance that this happens because I have no procedure in my file? The error disappears if I create one procedure in the file. Maybe there is a problem finding the right line where the procedure can be placed. If the error occurs, the procedure is not being created.

Output log:

[2020-05-27 10:33:19.444] [exthost] [error] [davidfeldhoff.al-codeactions] provider FAILED [2020-05-27 10:33:19.444] [exthost] [error] Error: Illegal argument: character must be non-negative at Object.t.illegalArgument (c:\Users\wbrakowski8911\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:10:784) at new e (c:\Users\wbrakowski8911\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:426:473) at new e (c:\Users\wbrakowski8911\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:424:44) at translate (c:\Users\wbrakowski8911\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:427:709) at ALSourceCodeHandler. (c:\Users\wbrakowski8911.vscode\extensions\davidfeldhoff.al-codeactions-0.2.9\out\extension\alSourceCodeHandler.js:84:90) at Generator.next () at fulfilled (c:\Users\wbrakowski8911.vscode\extensions\davidfeldhoff.al-codeactions-0.2.9\out\extension\alSourceCodeHandler.js:5:58) at processTicksAndRejections (internal/process/task_queues.js:85:5)

This is the file where it happens. Line with code "abc();" and "def();" are causing the errors.

`page 50102 "Report Overview Subpage" { PageType = ListPart; SourceTable = "Report Test"; Caption = 'Report Overview'; ShowFilter = true; // Editable = true; // ModifyAllowed = true; layout { area(content) { repeater(General) { field("Report ID"; "Report ID") { ApplicationArea = All; } field("Report Caption"; "Report Caption") { ApplicationArea = All; } field("List Page No."; "List Page No.") { ApplicationArea = All; } field("Card Page No."; "Card Page No.") { ApplicationArea = All; } field("Test Information"; "Test Information") { ApplicationArea = All; } } } } actions { area(Processing) { action(RunReport) { ApplicationArea = All; Promoted = true; PromotedOnly = true; PromotedIsBig = true; PromotedCategory = Report; Caption = 'Run selected Report'; trigger OnAction() begin RunReportModal(); end; } action(OpenCardPage) { ApplicationArea = All; Promoted = true; PromotedIsBig = true; PromotedOnly = true; PromotedCategory = Process; Image = Table; Caption = 'Open Card Page'; trigger OnAction() begin Page.Run("Card Page No."); def(); // Error end; } action(OpenListPage) { ApplicationArea = All; Promoted = true; PromotedIsBig = true; PromotedOnly = true; PromotedCategory = Process; Image = Table; Caption = 'Open List Page'; trigger OnAction() begin Page.Run("List Page No."); abc(); // Error end; } } }

} `

DavidFeldhoff commented 4 years ago

Ah, that's it. I just refactored that the last days to place them always in the right order (global procedures, local procedures, event subscribers etc.). Obviously something went wrong there :/ Thanks for looking deeper into that :)

DavidFeldhoff commented 4 years ago

I found the bug. It happened when you didn't have any procedure and if the object which was created didn't end with the }. Instead there were some trailing empty lines after that closing bracket. Too bad ^^ It's fixed in the version 0.2.10. Again thanks for reporting :)