Closed chrjorgensen closed 9 months ago
@chrjorgensen So we only know the source record length when SQL mode is enabled, which is how we provide the in-editor warning.
Do we also provide a new user setting (enabled by default) which will disable saving of files when a line of code is over the record length? This would only be available when source dates are enabled.
@worksofliam Source record length should always be considered, SQL mode enabled or not.
We can get the record length when SQL is disabled by DSPFD <lib>/<sourcefile> *RCDFMT
and extract the value from RFLEN
.
It would be logical to do this when opening the source file to retrieve the member list.
No user setting should be necessary... a warning should always be shown when trimmed source exceeds record length, but if you want to give the user the ultimate responsibility, you could provide an option Force
to force the save operation despite the data loss.
So we only know the source record length when SQL mode is enabled, which is how we provide the in-editor warning.
This is a false statement from myself. I believe we always know the record length, no matter if SQL is enabled or not.
Possible dupe of #1347
An alert user suggests adding rulers, which show vertical lines at the desired length. In settings JSON:
// Adds rulers to the screen at cols 80 & 100
"editor.rulers": [
80,
100
],
"workbench.colorCustomizations": {
"editorRuler.foreground": "#fa03032a"
},
Example of how it looks:
@alanseiden A good tip, which I also started using a long time ago... :smiley: This could even be turned into an option in this extension so the ruler will be set when a member is opened...
hope this #1764 help in the meaning time. This only shows a warning message after the member is saved.
Informing the user that some lines will be truncated before the saving process takes place would be ideal. Any efficient and effective way to do it? I was thinking of using the TextDocument and TextLine objects of the VS Code API.
on the other hand, I like the idea https://github.com/codefori/vscode-ibmi/issues/1172#issuecomment-1751665661 to set a vertical ruler when a member is opened but this should consider the user can open members from different source files that have different record lengths, so each member should have they own vertical rule. VS Code let set a vertical rule for all documents and per language but not for a specific open document.
Describe the bug
When a source member is opened in the editor and source lines longer than the maximum length are created, when the member is saved no warning is issued that lines will be truncated!
There is an indicator for lines exceeding the line length (the exceeding characters are underlined in read), but these lines may not be in the editor window. Or the exceeding characters may be too far to the right and thus outside the editor window.
I almost lost some source because of this - luckily I hadn't closed the editor when the compiler complained about garbage lines (phew)!
Expected behavior
There should be a pop-up warning the user that lines will be truncated if the user continues to save.