Browse Source

Backport PR #11271: Normalize cell source \r line endings (#11274)

Co-authored-by: Jason Grout <jasongrout@users.noreply.github.com>
MeeseeksMachine 3 years ago
parent
commit
f634c374bc
2 changed files with 5 additions and 3 deletions
  1. 4 2
      packages/cells/src/model.ts
  2. 1 1
      packages/codemirror/src/editor.ts

+ 4 - 2
packages/cells/src/model.ts

@@ -198,9 +198,11 @@ export class CellModel extends CodeEditor.Model implements ICellModel {
 
     // Set the text value, normalizing line endings to \n
     if (Array.isArray(cell.source)) {
-      this.value.text = cell.source.map(s => s.replace(/\r\n/g, '\n')).join('');
+      this.value.text = cell.source
+        .map(s => s.replace(/\r\n/g, '\n').replace(/\r/g, '\n'))
+        .join('');
     } else {
-      this.value.text = cell.source.replace(/\r\n/g, '\n');
+      this.value.text = cell.source.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
     }
     const metadata = JSONExt.deepCopy(cell.metadata);
     if (this.type !== 'raw') {

+ 1 - 1
packages/codemirror/src/editor.ts

@@ -1143,7 +1143,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
       )
     });
     console.warn(
-      'Please paste the following to https://github.com/jupyterlab/jupyterlab/issues/2951'
+      'If you are able and willing to publicly share the text or code in your editor, you can help us debug the "Code Editor out of Sync" message by pasting the following to the public issue at https://github.com/jupyterlab/jupyterlab/issues/2951. Please note that the data below includes the text/code in your editor.'
     );
     console.warn(
       JSON.stringify({