-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better handling of CRLF #693
Comments
Thanks @asleire! Thinking more about this, I think we could interecept the "will save document" event in the language server, and send back a notice (modal) to the client about disabling CRLF (or what have you) line endings if encountered in the document. We should only do that if the As a side note — one way to avoid having editors mess with this is to use an .editorconfig file at the project root, specifically for Rego. We do this in Regal, although we share the same config for both Rego and Go (as they follow the same conventions in this regard): https://github.com/StyraInc/regal/blob/main/.editorconfig I'm not sure VS Code uses this file without custom extensions, but GitHub and IntellJ certainly do. |
That sounds great!
Yes, it shouldn't be difficult in most IDEs to use LF endings |
In case either `opa-fmt` or `use-rego-v1` is enabled, we'll send back a warning to the client whenever they save a document containing CRLF line endings. This to avoid confusion when the user tries to fix formatting using `opa fmt`, but the editor adding back CRLF line endings after. Also disable the nestif linter, as it's annoying. Fixes #693 Signed-off-by: Anders Eknert <anders@styra.com>
In case either `opa-fmt` or `use-rego-v1` is enabled, we'll send back a warning to the client whenever they save a document containing CRLF line endings. This to avoid confusion when the user tries to fix formatting using `opa fmt`, but the editor adding back CRLF line endings after. Also disable the nestif linter, as it's annoying. Fixes #693 Signed-off-by: Anders Eknert <anders@styra.com>
In case either `opa-fmt` or `use-rego-v1` is enabled, we'll send back a warning to the client whenever they save a document containing CRLF line endings. This to avoid confusion when the user tries to fix formatting using `opa fmt`, but the editor adding back CRLF line endings after. Also disable the nestif linter, as it's annoying. Fixes #693 Signed-off-by: Anders Eknert <anders@styra.com>
In case either `opa-fmt` or `use-rego-v1` is enabled, we'll send back a warning to the client whenever they save a document containing CRLF line endings. This to avoid confusion when the user tries to fix formatting using `opa fmt`, but the editor adding back CRLF line endings after. Also disable the nestif linter, as it's annoying. Fixes StyraInc#693 Signed-off-by: Anders Eknert <anders@styra.com>
As discussed in Styra community Slack there is an issue with the
opa-fmt
rule, Windows' line endings and IDEs like VS Code that automatically changes line endings.Regal shows a warning when the file contains
CRLF
line endings. Runningopa fmt
through the IDE does not fix the warning because whenopa fmt
outputsLF
line endings the IDE automatically changes theLF
line endings toCRLF
line endings.Users can usually fix this quite easily by configuring their IDE to use
LF
endings, but the the problem ofCRLF
line endings is not obvious for users to begin with. It would be nice if Regal could somehow let the user know about the issue withCRLF
line endings.I have two ideas on how this could be improved:
CRLF
. Maybe the message could be dynamic and only include a note aboutCRLF
if such endings are found in the file?CRLF
endingsThe text was updated successfully, but these errors were encountered: