Convert line endings when copy and pasting#19016
Conversation
|
Note: this won't affect pasting in Atom that much: copying LF and pasting it into another LF file will still result in LF line endings, not CRLF. |
|
Hmm, this breaks some tests. I can add a boolean option whether to do the conversion or not. |
|
Hey! 👋 We have recently started using This is good news: now the Atom code is more consistent and it's much easier to re-format the code to This change caused conflicts on your PR that we have automatically solved, hope you don't mind 😄 With ❤️, the Atom team. |
18b9657 to
72b21d1
Compare
sadick254
left a comment
There was a problem hiding this comment.
Hey @50Wliu, I have just resolved some conflicts on this and I think it's good to go. Thank you for your contribution.
|
@sadick254 feel free to merge, I really shouldn't have merge permissions anymore :). |
7a2ff51 to
b9f6cdd
Compare
15914ab to
c8cda7f
Compare
Compare against the platforms eol marker.
c8cda7f to
c8f3f86
Compare
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.