Skip to content

Commit

Permalink
fix #105916. expand metadata section if modified.
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Sep 9, 2020
1 parent e491efb commit 4e70e4a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ abstract class AbstractCellRenderer extends Disposable {
this._metadataHeaderContainer = DOM.append(this._diffEditorContainer, DOM.$('.metadata-header-container'));
this._metadataInfoContainer = DOM.append(this._diffEditorContainer, DOM.$('.metadata-info-container'));

const checkIfModified = (cell: CellDiffViewModel) => {
return cell.type !== 'delete' && cell.type !== 'insert' && hash(this._getFormatedMetadataJSON(cell.original?.metadata || {}, cell.original?.language)) !== hash(this._getFormatedMetadataJSON(cell.modified?.metadata ?? {}, cell.modified?.language));
};

if (checkIfModified(this.cell)) {
this.cell.metadataFoldingState = PropertyFoldingState.Expanded;
}

this._metadataHeader = this.instantiationService.createInstance(
PropertyHeader,
this.cell,
Expand All @@ -291,7 +299,7 @@ abstract class AbstractCellRenderer extends Disposable {
{
updateInfoRendering: this.updateMetadataRendering.bind(this),
checkIfModified: (cell) => {
return cell.type !== 'delete' && cell.type !== 'insert' && hash(this._getFormatedMetadataJSON(cell.original?.metadata || {}, cell.original?.language)) !== hash(this._getFormatedMetadataJSON(cell.modified?.metadata ?? {}, cell.modified?.language));
return checkIfModified(cell);
},
getFoldingState: (cell) => {
return cell.metadataFoldingState;
Expand All @@ -311,6 +319,14 @@ abstract class AbstractCellRenderer extends Disposable {
this._outputHeaderContainer = DOM.append(this._diffEditorContainer, DOM.$('.output-header-container'));
this._outputInfoContainer = DOM.append(this._diffEditorContainer, DOM.$('.output-info-container'));

const checkIfOutputsModified = (cell: CellDiffViewModel) => {
return cell.type !== 'delete' && cell.type !== 'insert' && !this.notebookEditor.textModel!.transientOptions.transientOutputs && cell.type === 'modified' && hash(cell.original?.outputs ?? []) !== hash(cell.modified?.outputs ?? []);
};

if (checkIfOutputsModified(this.cell)) {
this.cell.outputFoldingState = PropertyFoldingState.Expanded;
}

this._outputHeader = this.instantiationService.createInstance(
PropertyHeader,
this.cell,
Expand All @@ -319,10 +335,10 @@ abstract class AbstractCellRenderer extends Disposable {
{
updateInfoRendering: this.updateOutputRendering.bind(this),
checkIfModified: (cell) => {
return cell.type !== 'delete' && cell.type !== 'insert' && !this.notebookEditor.textModel!.transientOptions.transientOutputs && cell.type === 'modified' && hash(cell.original?.outputs ?? []) !== hash(cell.modified?.outputs ?? []);
return checkIfOutputsModified(cell);
},
getFoldingState: (cell) => {
return this.cell.outputFoldingState;
return cell.outputFoldingState;
},
updateFoldingState: (cell, state) => {
cell.outputFoldingState = state;
Expand Down

0 comments on commit 4e70e4a

Please sign in to comment.