Skip to content

Commit

Permalink
Fix diff for new and removed notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Collonval committed Mar 2, 2021
1 parent 820b11c commit 57d080e
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/components/diff/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ export class NotebookDiff extends Panel {
currentContent: headContent
}
);
data['baseMapping'] = Private.computeNotebookMapping(baseContent) as any;
data['headMapping'] = Private.computeNotebookMapping(headContent) as any;
data['baseMapping'] = Private.computeNotebookMapping(
baseContent || '{}'
) as any;
data['headMapping'] = Private.computeNotebookMapping(
headContent || '{}'
) as any;
return data;
}

Expand Down Expand Up @@ -294,15 +298,17 @@ namespace Private {

return {
metadata: {
start: parsedContent.pointers['/metadata'].key.line,
end: parsedContent.pointers['/metadata'].valueEnd.line
start: parsedContent.pointers['/metadata']?.key.line,
end: parsedContent.pointers['/metadata']?.valueEnd.line
},
cells: parsedContent.data.cells.map((cell: any, index: number) => {
return {
start: parsedContent.pointers[`/cells/${index}`].value.line,
end: parsedContent.pointers[`/cells/${index}`].valueEnd.line
};
})
cells: (parsedContent.data.cells || []).map(
(cell: any, index: number) => {
return {
start: parsedContent.pointers[`/cells/${index}`].value.line,
end: parsedContent.pointers[`/cells/${index}`].valueEnd.line
};
}
)
};
}
/**
Expand Down

0 comments on commit 57d080e

Please sign in to comment.