This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Convert line endings when copy and pasting #19016
Merged
+65
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements for Adding, Changing, or Removing a Feature
Issue or RFC Endorsed by Atom's Maintainers
#8365, endorsed by @maxbrunsfeld here.
Description of the Change
Whenever text is copied to the clipboard, all line endings are converted to the underlying OS's default line endings (CRLF on Windows, LF otherwise). Fixes #8365.
Alternate Designs
I could have done
const os = require('os')and then usedos.EOLinstead of hardcoding the line endings inclipboard.js, but that didn't seem worth it.This could also be implemented as a Windows-only feature, which I believe is how VSCode does it.
Possible Drawbacks
Sometimes you may want to explicitly copy the text as-is without conversions, and this will prevent that.
Verification Process
On Windows, I copied text with LF line endings and pasted them into http://www.unit-conversion.info/texttools/hexadecimal/, which confirmed that the pasted text had
0d 0a(CRLF).Release Notes
Line endings are now converted when copy and pasting.