Skip to content

Commit 35ae55a

Browse files
committed
diff editor output decorations fix.
1 parent aac461a commit 35ae55a

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,40 +1385,44 @@ export class ModifiedElement extends AbstractElementRenderer {
13851385

13861386
this._outputLeftContainer = DOM.append(this._outputViewContainer!, DOM.$('.output-view-container-left'));
13871387
this._outputRightContainer = DOM.append(this._outputViewContainer!, DOM.$('.output-view-container-right'));
1388+
1389+
if (this.cell.checkIfOutputsModified()) {
1390+
const originalOutputRenderListener = this.notebookEditor.onDidDynamicOutputRendered(e => {
1391+
if (e.cell.uri.toString() === this.cell.original.uri.toString()) {
1392+
this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, ['nb-cellDeleted'], []);
1393+
originalOutputRenderListener.dispose();
1394+
}
1395+
});
1396+
1397+
const modifiedOutputRenderListener = this.notebookEditor.onDidDynamicOutputRendered(e => {
1398+
if (e.cell.uri.toString() === this.cell.modified.uri.toString()) {
1399+
this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, ['nb-cellAdded'], []);
1400+
modifiedOutputRenderListener.dispose();
1401+
}
1402+
});
1403+
1404+
this._register(originalOutputRenderListener);
1405+
this._register(modifiedOutputRenderListener);
1406+
}
1407+
13881408
// We should use the original text model here
13891409
this._outputLeftView = this.instantiationService.createInstance(OutputContainer, this.notebookEditor, this.notebookEditor.textModel!, this.cell, this.cell.original!, DiffSide.Original, this._outputLeftContainer!);
13901410
this._outputLeftView.render();
13911411
this._register(this._outputLeftView);
13921412
this._outputRightView = this.instantiationService.createInstance(OutputContainer, this.notebookEditor, this.notebookEditor.textModel!, this.cell, this.cell.modified!, DiffSide.Modified, this._outputRightContainer!);
13931413
this._outputRightView.render();
13941414
this._register(this._outputRightView);
1395-
1396-
const originalOutputRenderListener = this.notebookEditor.onDidDynamicOutputRendered(e => {
1397-
if (e.cell.uri.toString() === this.cell.original.uri.toString()) {
1398-
this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, ['nb-cellDeleted'], []);
1399-
originalOutputRenderListener.dispose();
1400-
}
1401-
});
1402-
1403-
const modifiedOutputRenderListener = this.notebookEditor.onDidDynamicOutputRendered(e => {
1404-
if (e.cell.uri.toString() === this.cell.modified.uri.toString()) {
1405-
this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, ['nb-cellAdded'], []);
1406-
modifiedOutputRenderListener.dispose();
1407-
}
1408-
});
1409-
1410-
this._register(originalOutputRenderListener);
1411-
this._register(modifiedOutputRenderListener);
1412-
14131415
this._decorate();
14141416
}
14151417

14161418
this._outputViewContainer.style.display = 'block';
14171419
}
14181420

14191421
_decorate() {
1420-
this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, ['nb-cellDeleted'], []);
1421-
this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, ['nb-cellAdded'], []);
1422+
if (this.cell.checkIfOutputsModified()) {
1423+
this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Original, this.cell.original.id, ['nb-cellDeleted'], []);
1424+
this.notebookEditor.deltaCellOutputContainerClassNames(DiffSide.Modified, this.cell.modified.id, ['nb-cellAdded'], []);
1425+
}
14221426
}
14231427

14241428
_showOutputsRenderer() {

src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,26 +196,26 @@
196196
overflow: hidden;
197197
}
198198

199-
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container.modified .output-view-container .output-view-container-left {
199+
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container .output-view-container .output-view-container-left {
200200
top: 0;
201201
position: absolute;
202202
left: 0;
203203
}
204204

205-
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container.modified .output-view-container .output-view-container-right {
205+
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container .output-view-container .output-view-container-right {
206206
position: absolute;
207207
top: 0;
208208
left: 50%;
209209
}
210210

211-
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container.modified .output-view-container .output-view-container-left,
212-
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container.modified .output-view-container .output-view-container-right {
211+
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container .output-view-container .output-view-container-left,
212+
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container .output-view-container .output-view-container-right {
213213
width: 50%;
214214
display: inline-block;
215215
}
216216

217-
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container.modified .output-view-container .output-view-container-left div.foreground,
218-
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container.modified .output-view-container .output-view-container-right div.foreground {
217+
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container .output-view-container .output-view-container-left div.foreground,
218+
.monaco-workbench .notebook-text-diff-editor .cell-body.full .output-info-container .output-view-container .output-view-container-right div.foreground {
219219
width: 100%;
220220
}
221221

src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ function webviewPreloads() {
561561

562562
postNotebookMessage<IDimensionMessage>('dimension', {
563563
id: outputId,
564+
isOutput: true,
564565
init: true,
565566
data: {
566567
height: outputNode.clientHeight
@@ -642,6 +643,7 @@ function webviewPreloads() {
642643

643644
postNotebookMessage<IDimensionMessage>('dimension', {
644645
id: outputId,
646+
isOutput: true,
645647
data: {
646648
height: output.clientHeight
647649
}

0 commit comments

Comments
 (0)