Search Unity

Feedback Fix inconsistent line endings in script files automatically

Discussion in 'Editor & General Support' started by Peter77, Jul 18, 2019.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Unity outputs the following warning if it detects inconsistent line endings in scripts:
    Unity provides an option to specify line ending for new scripts already:
    upload_2019-7-18_15-12-33.png

    I would like to suggest to add another option here that fixes line endings automatically, so I don't need to open each file in a text editor that supports those conversion.

    If Unity detects line endings are not as specified as in the new "Force Line Endings For Scripts" setting, it would fix those automatically.

    The new "Force Line Endings For Scripts" setting should provide the same modes: OS Native, Unity, Windows and additionally "Disabled".

    Thank you.
     
    Last edited: Jul 18, 2019
  2. Vectorbox

    Vectorbox

    Joined:
    Jan 27, 2014
    Posts:
    232
    It would be a useful update, but if you're using Visual Studio you could install the free 'Stripem' add-on which offers both manual and automatic recognition and correction.

    Link
    Stripem by Itay Szekely
     
    Last edited: Jul 19, 2019
    TobiMercader and Peter77 like this.
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I generally like the idea, but I also want to chime in with concerns regarding large projects and performance. Unity already parses all script files and checks their line endings, which itself should be a fast process. However, automatically fixing the line endings might be slow when there are many large script files in the project. This would need to be profiled, to make a decision, but in case this would cause any slowdowns, I would prefer a menu command to fix line endings at a convenient time. As a worst case, in a project I was working on, we had a dozen script files with approx. 35k lines of generated code. So, I would benchmark with this scope.

    If this feature would be optional, it wouldn't harm anyone who doesn't use it, however, automatically changing script files can also cause unwanted merge conflicts for users in teams, which speaks against the usefulness of this feature. For example, if I see a few logs, I as one of many developers, can go through the list and fix my own scripts one by one in Visual Studio and then commit to source control. If Unity would automatically fix all scripts, I could be causing merge conflicts with developers who are currently refactoring the same classes and make many changes.
     
    Last edited: Jul 18, 2019
    Peter77 likes this.
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'd like this, gets on my tits tbh.
     
  5. lucbloom

    lucbloom

    Joined:
    Mar 27, 2020
    Posts:
    42
    "Many text editors" apparently doesn't include Unity itself.
    When will these tool programmers realise nobody cares about line endings in 2020? Or actually, nobody should care but somehow we are taught to have an opinion about it. By GIT and now by Unity devs. They can take away that completely unnecessary noise by just ignoring that stuff and deal with it in the Editor itself. Visual Studio can do that, Beyond Compare can do that, Notepad++ can do that... so just go back with your warning to 1988.
    Unity should not be educating me about the dangers of mixed line endings. Show me a tool that doesn't function without correct line endings and I'll show you how that's irrelevant because I'm not using that tool.
    /rant
     
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    andyz likes this.
  7. Lord_Eniac

    Lord_Eniac

    Joined:
    Jan 28, 2020
    Posts:
    50
    If we could disable the stupid (IMO) warning from Unity's console tab. That'd be awesome.
     
  8. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    True, I don't understand what's the point of spamming users with useless warnings that don't affect anything
     
    lucbloom likes this.
  9. Skeckulous

    Skeckulous

    Joined:
    Sep 21, 2017
    Posts:
    8
    Or just have it autocorrect the lines... It could even give you an option, if you really feel it might be an issue with slowing down build time. But this is crazy annoying because it can lead to issues finding where your errors are occurring in your scripts.
     
  10. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,267
    Ah the unending problem with Unity and Visual Studio - I hate this warning in Unity and probably there will be an option to ignore soon as I believe one is coming for 'minor' warnings.
    Until then if Unity and Visual Studio could just auto-sync on line endings it would be nice as I forget the best work-around and VS plugins get lost as versions change!
     
  11. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,267
  12. SinTrace

    SinTrace

    Joined:
    Jan 3, 2017
    Posts:
    14
    If you use VS, please create a new script directly, copy and paste
    As for the VS Preferences setting, it is useless for me
    Screen Shot 2021-02-02 at 2.56.46 PM.png

    If you use VSCode, you can change the settings in the lower right corner
    Screen Shot 2021-02-02 at 2.51.43 PM.png
     
    Last edited: Feb 2, 2021