Skip to content
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

Preserve newlines on copy + paste #83

Merged
merged 4 commits into from
Nov 29, 2020
Merged

Conversation

JonShort
Copy link
Contributor

Adresses #78

Currently when copy + pasting, empty lines are not preserved in the output, which could be unexpected for the user.

Changes

Adding a newline \n as the content for empty rows seems to help preserve newlines when copy + pasting; without adding any additional characters (e.g. whitespace) or changing the visuals.

I've tested this on macOS & windows, but haven't been able to test on a linux device

Tests

Local:

[x] macOS
[x] Windows
[ ] Unix

Unit tests:

  • Updated to expect \n as content for empty lines

Snapshots:

  • Updated as empty line spans are no-longer self-closing

Examples

I shimmed this functionality into the codesandbox example, so it can be tested:
https://codesandbox.io/s/prism-react-renderer-example-r8dl3

note - the line numbers example seems to paste with extra newlines even in the original example, so I don't think there's a regression there

Pasted from examples:

Current

(function someDemo() {
  var test = "Hello World!";
  console.log(test);
})();
return () => <App />;

Updated

(function someDemo() {
  var test = "Hello World!";
  console.log(test);
})();

return () => <App />;

@kitten kitten merged commit 55c105f into FormidableLabs:master Nov 29, 2020
@manuelpuyol manuelpuyol mentioned this pull request Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants