-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
With wrapLongLines and showLineNumbers both enabled, if we copy some code, all code formatting, spaces, styles etc. is lost #432
Comments
I also encountered this problem. Is there a solution |
We also have the same issue. Usage: |
I also ran into this. I traced the issue down to: react-syntax-highlighter/src/highlight.js Lines 119 to 121 in b0d7714
I'm not sure why this code is necessary; for me, if I just remove it, everything behaves correctly in my app while using these settings together. Specifically, I'm using the following diff with diff --git a/node_modules/react-syntax-highlighter/dist/cjs/highlight.js b/node_modules/react-syntax-highlighter/dist/cjs/highlight.js
index 31ad1d4..7adfd33 100644
--- a/node_modules/react-syntax-highlighter/dist/cjs/highlight.js
+++ b/node_modules/react-syntax-highlighter/dist/cjs/highlight.js
@@ -122,12 +122,6 @@ function createLineElement(_ref3) {
children.unshift(getInlineLineNumber(lineNumber, inlineLineNumberStyle));
}
- if (wrapLongLines & showLineNumbers) {
- properties.style = _objectSpread(_objectSpread({}, properties.style), {}, {
- display: 'flex'
- });
- }
-
return {
type: 'element',
tagName: 'span',
diff --git a/node_modules/react-syntax-highlighter/dist/esm/highlight.js b/node_modules/react-syntax-highlighter/dist/esm/highlight.js
index 8e78a19..be8c674 100644
--- a/node_modules/react-syntax-highlighter/dist/esm/highlight.js
+++ b/node_modules/react-syntax-highlighter/dist/esm/highlight.js
@@ -107,12 +107,6 @@ function createLineElement(_ref3) {
children.unshift(getInlineLineNumber(lineNumber, inlineLineNumberStyle));
}
- if (wrapLongLines & showLineNumbers) {
- properties.style = _objectSpread(_objectSpread({}, properties.style), {}, {
- display: 'flex'
- });
- }
-
return {
type: 'element',
tagName: 'span',
diff --git a/node_modules/react-syntax-highlighter/src/highlight.js b/node_modules/react-syntax-highlighter/src/highlight.js
index e84eb3a..39f7a43 100644
--- a/node_modules/react-syntax-highlighter/src/highlight.js
+++ b/node_modules/react-syntax-highlighter/src/highlight.js
@@ -116,10 +116,6 @@ function createLineElement({
children.unshift(getInlineLineNumber(lineNumber, inlineLineNumberStyle));
}
- if (wrapLongLines & showLineNumbers) {
- properties.style = { ...properties.style, display: 'flex' };
- }
-
return {
type: 'element',
tagName: 'span', If anyone wants to open a PR with this feel free, I tried to build/run tests/etc. but it didn't work with my currently installed version of nodejs, and I didn't have time to look into it further now. |
Describe the bug
With wrapLongLines and showLineNumbers both enabled, if we copy some code, all code formatting, spaces, stykes etc. are lost
To Reproduce
Steps to reproduce the behavior:
Note: the above mentioned issue doesn't occur if we set showLineNumbers={false}
Expected behavior
code formatting, spaces, styles etc. should be preserved on pasting it in any code editor
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: