question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide option to opt out of line ending normalisation for files

See original GitHub issue

Upon saving a file edited with VS Code, it appears to perform line ending normalisation automatically and without user notification of any sort. Because of this, I’ve found myself bitten by large diffs in Git (I’m aware you can circumvent this using the -w flag) where a trivial fix to a single line of source code appears to affect a significant proportion of the file, which makes pull requests and reviews for such changes on GitHub a pain to sift through. Then again, I guess one could argue why a source file with mixed line endings should stay in version control like that anyway!

Visual Studio Community displays a prompt upon opening a file if it has mixed line endings and lets a user decide whether or not to have it fixed.

Version: 0.10.1

(By the way, great work on open sourcing VS Code too, thanks!)

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:82
  • Comments:51 (2 by maintainers)

github_iconTop GitHub Comments

46reactions
smlamcommented, Dec 12, 2018

EOL normalization should be optional feature and off by default. We do not expect file editor will change non-edited code without user conscious.

Thanks

44reactions
finn-matticommented, Jun 3, 2020

Concrete examples where this is a problem (from this thread):

  • PRs/Changes to repos with mixed line endings become impossible to do (because much bigger diffs are generated by the normalization)
  • You might think that mixed line endings are a bad idea, but are not in a position to change current policy
  • Makes editing files with binary payloads impossible (shell scripts with binary blob)
  • Cross platform dev teams might suffer from normalization ping pong
  • editing .gitignore files with Icon\r\r lines in VS Code will break these files behavior (in any case everyone has to be aware of the issue to make the workaround of using Icon? work)
  • SQL exports which contain LF as line endings but also CRLF within multi-line text fields
  • XML documents with CDATA entries with different line endings cannot be edited savely
  • unable to editing raw HTTP requests and responses through the Monaco Editor
  • Working on PDF files with mixed lines endings becomes impossible

My own example: files for tests (since some external systems work with differnet line endings) cannot be edited in VS Code. If for some reason I have to edit a testfile with mixed line endings I will lose what a test case is supposed to test.

I don’t know if about 10 different examples collected over 5 years is enough to persuade somebody to work on this. But it’s a persistent open issue and therefore should at least be reevaluated, imho. I for one would love to hear some member giving this another look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode warning: LF will be replaced by CRLF in
If your file has mixed line ending, there is no option to opt out of line ending normalisation for files, meaning, upon saving...
Read more >
Line Endings - RAD Studio - Embarcadero DocWiki
RAD Studio requires CRLF line endings (Windows standard) and can detect and normalize when a file is not consistently CRLF, but has a...
Read more >
CRLF vs. LF: Normalizing Line Endings in Git
A better solution is to add a .gitattributes file to your repo so you can enforce line endings consistently in your codebase regardless...
Read more >
Inconsistent line endings in VS 2017 - MSDN - Microsoft
If you are modifying the code to be used on linux on VS, you should choose which line ending to use. If you...
Read more >
File Signature Normalization
Choose your release version ... End of Life (EOL) and End of Support (EOS) life cycles ... Opt-in to the Hardware Asset Management...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found