-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add a line ending (CRLF vs LF) setting #897
Comments
Wouldn't it be better to configure your Git client to always commit files with LF line endings?
To convert files that were committed before setting this option, use See Customizing Git configuration for more information. |
As I noted in the original issue, dos2unix will not recognize many files as text files, and therefore will do nothing. (IIRC it completely ignored tscn, escn, res and tres, and I'm not sure if it got .gd, either) (As for Git client - valid point, but at the time I started working on those, I was exclusively on Windows and didn't know about that setting, and now I'm wary of switching that as it might mess up other forks) |
I don't think there should be a setting, it should just always use LF line endings. The vast majority of tools on Windows support LF just fine, even Notepad supports LF. There are many ways to enforce this for your project using external tools. Git has the I recommend using the
|
Thanks for the tip re: the formatting script. Yes, always using LF would probably be an even simpler solution to the problem. |
Closing and archiving, as the solution is "it's better to always use LF and Godot currently does this". |
Why archive? Windows, by default, uses CRLF and Godot does not currently "do this [referring to always using LF], as evidenced by the fact my files were full of carriage returns. |
@Zireael07 Can you provide the steps to reproduce this? I just created an empty project with Godot 3.2.3rc3 on Windows, then created a GDScript file, and it was filled with LF, no carriage returns anywhere. |
It was several months ago, but I believe I manually copied a Godot project from Windows 7 to the Linux laptop. It was likely created in Godot 3.1. or even earlier. Or maybe I pulled from a Git repo that was not configured as autocrlf true - as I said, it was quite a long time ago. (It's likely that a new project in a newer version will use LF indeed, but many people have started with older versions and simply migrated them to each new patch version) |
@aaronfranke This is actually an issue when versioning Godot files. I just spent the past 3 days collaborating on a small mini game with 3 other people, and I must say that the git experience was hectic thanks to Godot not using CRLF. Git for Windows has a The biggest pain now of having Godot use LF on Windows is that the git client will mark all the files with LF returns as different when doing I think that it should be an option at the very least, and bonus point to make it CRLF by default on Windows. |
Ok just saw this. Not sure what to think about it. On one hand I feel it would be nice for Godot to use the correct platform line ending, but on the other hand I understand you guys prefer giving users the responsibility of handling the issue. Meh. |
CRLF is only expected on Windows for legacy applications. Modern applications should use LF everywhere. With Godot, you should always have |
@marechal-p: I had the opposite problem, git diff tripping on Linux because of the CRLF. As I said, I don't remember if I used git, maybe I copied files manually. And dos2unix ran on the whole folder completely ignored tscn and escn - otherwise I wouldn't have had the problem that led to creating this issue. |
I just opened a PR to mention this in the docs: godotengine/godot-docs#3891 |
I'm also affected by this, but not because of git (autocrlf does the trick). Rather, I'm using C# with Visual Studio, which always uses CRLF. And Godot always uses LF. And I often need to have files open in different editors because of the way debugging and error reporting works. So while all the files use CRLF, Godot keeps overwriting them with LF and causing Visual Studio to complain about inconsistent line endings. There's no reason not to have an option for this, you're just taking power away from the user. By all means, try and set up the default value such that most users won't have to change it. But some people always will. |
@Avantir-Chaosfire You can configure Visual Studio to use LF as stated in this documentation: https://docs.microsoft.com/en-us/visualstudio/ide/encodings-and-line-breaks?view=vs-2019 |
@aaronfranke You can configure that on file by file basis, but not for Visual Studio as a whole. |
I just encountered this problem in Godot 4.0.beta6 and would sure like Godot either to always use the same line endings regardless of plattform (apparently it still doesn't) or allow the user to specify what to use for a project. In my case I use a mac as my main development computer and use a github repository for the code. If I download the project to my windows machine and open the project in Godot there it rewrites and changes the line endings on all .import and .tres files in the project, so git shows they're all modified with new line endings but no changes in content. So apparently the line endings are still different at least between mac and windows, and also for some reason Godot overwrites all these files as a part of loading the project even if you don't modify anything? |
@lostminds Git has a setting to convert line endings when you checkout or pull to match the local system, and to convert them back when you push. This is pretty much a must-have setting when you work across multiple operating systems, and it should solve your problems. |
@YuriSizov Not everyone uses Git, though! At the time of opening this issue, the project I was working on was a throwaway thing, so no Git either... |
@Zireael07 Yeah, that's fair, I was just addressing the case from the comment where Git is used. |
@lostminds I can't reproduce this issue, any operations I perform using Godot on Windows result in the files staying LF. |
@aaronfranke I just tried it again and this time it didn't change any of the .import files (may have been because last time was the first time I ran 4.0.beta6 on windows, so it re-imported all assets). But still it changed all shader .tres files, the Theme.tres file and the .godot project file from LF to CRLF line endings according to my github client. While I didn't modify or work with any of these files I did export the project (for windows), but in my mind that shouldn't modify any of these files. |
What do you mean by "it changed"? When you just "open the project in Godot"? Godot does not take it upon itself to go into all your files and modify them. Unless it's part of an open scene in the editor, Godot won't change the files on disk. If you open and close the Godot editor without opening any scenes, it won't change anything in your project (except project.godot). So, please describe the specific actions you are doing. My suspicion is that you have Git configured incorrectly (run |
Ok, to be more specific: If I just open the project in Godot, this also loaded two scenes that were open last time I opened the project. This as you suspected does not modify any files, except for the project .godot file which gets the line endings changed as soon as the project is opened. If I then immediately run the game from the editor without doing anything else the rest of the files mentioned above get changed. In other words the visual shader .tres files (8-9 of them) and the UITheme .tres file get modified changing the line endings from LF to CRLF. I understand that there is a git setting like you mention to compensate for this issue by having git convert the line endings like you and others have mentioned. However, that's just a way to work around with the issue, and I don't see how that could be the cause of the files being changed by godot when running the project? While I guess technically possible I think it seems unlikely that the issue is the git client incorrectly reporting the change in line endings. |
@lostminds This is a sad consequence of two issues: one, that Godot opens and resaves the project .godot file when it opens - this once caused me to not be able to open projects, when I had a sneaky drive failure that first manifested as this problem; and two, save on run, which is generally a good thing, but in this case it seems to change the line endings. Even more reason to have a line ending setting |
@Zireael07 Indeed. According to the discussion above Godot should never output CRLF line endings at all, which would also be fine for me. So hopefully this is just a bug that will be fixed. Regarding save on run I think it's fine and sort of expected for modified open scenes and resources once you know about it. But it's unexpected to me that it would re-save shader resources that haven't been modified, so maybe that is also a separate bug and the CRLF issue just makes it visible. |
Working with Godot and C# with Visual Studio 2022 on Windows 10, I'm constantly getting this dialog when opening files in VS, it's a pain: Generally, most applications use the environment line ending for the system they're on, for Windows, that'd be CRLF. So, it'd be nice to see at least a setting/option for this rather than having to reconfigure a bunch of my other tools and configuration that I use for other projects/environments fine on Windows elsewhere already today. |
@hawkerm I recommend configuring Visual Studio to use LF instead. This way your files will have consistent line endings regardless of operating system. Plus, if Git strips the carriage returns, or if you copy a file from Mac/Linux, you will have to deal with LF on Windows anyway. |
Forcing the user to use a specific line ending without possibility of customisation does not sound great |
Describe the project you are working on:
N/A (this is a generic issue)
Describe the problem or limitation you are having in your project:
Copying files from Windows to Linux machine causes spurious ^M (line feed) characters.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Line ending setting would make it possible for Windows Godot not to add line feed characters, making projects truly cross-platform.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
A line ending setting similar to the one most IDEs have (PyCharm, Sublime Text 3) and/or a CRLF to LF switch button.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
Nope.
Is there a reason why this should be core and not an add-on in the asset library?:
Not possible to do outside of core (has to be done in script editor) and not necessary for GDScript-exposed parts of script editor.
Related: godotengine/godot#27057
The text was updated successfully, but these errors were encountered: