Browse Source

Merge pull request #2752 from ian-r-rose/fix_cell_format_decoding

Join cells source lines with empty string.
Steven Silvester 7 years ago
parent
commit
ef4079912b
2 changed files with 5 additions and 5 deletions
  1. 1 1
      packages/cells/src/model.ts
  2. 4 4
      test/src/cells/model.spec.ts

+ 1 - 1
packages/cells/src/model.ts

@@ -152,7 +152,7 @@ class CellModel extends CodeEditor.Model implements ICellModel {
     delete cell.metadata['trusted'];
 
     if (Array.isArray(cell.source)) {
-      this.value.text = (cell.source as string[]).join('\n');
+      this.value.text = (cell.source as string[]).join('');
     } else {
       this.value.text = cell.source as string;
     }

+ 4 - 4
test/src/cells/model.spec.ts

@@ -54,12 +54,12 @@ describe('cells/model', () => {
       it('should accept a base cell argument with a multiline source', () => {
         let cell: nbformat.IRawCell = {
           cell_type: 'raw',
-          source: ['foo', 'bar', 'baz'],
+          source: ['foo\n', 'bar\n', 'baz'],
           metadata: { trusted: false }
         };
         let model = new CellModel({ cell });
         expect(model).to.be.a(CellModel);
-        expect(model.value.text).to.equal((cell.source as string[]).join('\n'));
+        expect(model.value.text).to.equal((cell.source as string[]).join(''));
       });
 
     });
@@ -216,11 +216,11 @@ describe('cells/model', () => {
       it('should always return a string source', () => {
         let cell: nbformat.IRawCell = {
           cell_type: 'raw',
-          source: ['foo', 'bar', 'baz'],
+          source: ['foo\n', 'bar\n', 'baz'],
           metadata: { trusted: false }
         };
         let model = new TestModel({ cell });
-        cell.source = (cell.source as string[]).join('\n');
+        cell.source = (cell.source as string[]).join('');
         expect(model.toJSON()).to.not.equal(cell);
         expect(model.toJSON()).to.eql(cell);
       });