Skip to content

Commit e85b3ba

Browse files
committed
border around the whole cell.
1 parent 8b1f7df commit e85b3ba

3 files changed

Lines changed: 23 additions & 29 deletions

File tree

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

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as DOM from 'vs/base/browser/dom';
77
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
8-
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
8+
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
99
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1010
import { CellDiffViewModel, MetadataFoldingState } from 'vs/workbench/contrib/notebook/browser/diff/celllDiffViewModel';
1111
import { CellDiffRenderTemplate, CellDiffViewModelLayoutChangeEvent, INotebookTextDiffEditor } from 'vs/workbench/contrib/notebook/browser/diff/common';
@@ -21,7 +21,7 @@ import { NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/noteb
2121
import { hash } from 'vs/base/common/hash';
2222

2323

24-
const fixedDiffEditorOptions: IEditorOptions = {
24+
const fixedDiffEditorOptions: IDiffEditorOptions = {
2525
padding: {
2626
top: 12,
2727
bottom: 12
@@ -44,7 +44,9 @@ const fixedDiffEditorOptions: IEditorOptions = {
4444
glyphMargin: true,
4545
fixedOverflowWidgets: true,
4646
minimap: { enabled: false },
47-
renderValidationDecorations: 'on'
47+
renderValidationDecorations: 'on',
48+
enableSplitViewResizing: false,
49+
renderIndicators: false
4850
};
4951

5052
const fixedEditorOptions: IEditorOptions = {
@@ -111,6 +113,7 @@ abstract class AbstractCellRenderer extends Disposable {
111113
bodyMargin: 16
112114
};
113115
this._metadataEditorDisposeStore = new DisposableStore();
116+
this._register(this._metadataEditorDisposeStore);
114117
this.initData();
115118
this.buildBody(templateData.container);
116119
this._register(cell.onDidLayoutChange(e => this.onDidLayoutChange(e)));
@@ -227,7 +230,7 @@ abstract class AbstractCellRenderer extends Disposable {
227230

228231
private _buildMetadataEditor() {
229232
if (this.cell.type === 'modified') {
230-
const originalMetadataSource = this._getFormatedJSON(this.cell.original!.metadata || {});
233+
const originalMetadataSource = this._getFormatedJSON(this.cell.original?.metadata || {});
231234
const modifiedMetadataSource = this._getFormatedJSON(this.cell.modified?.metadata || {});
232235
if (originalMetadataSource !== modifiedMetadataSource) {
233236
this._metadataEditor = this.instantiationService.createInstance(DiffEditorWidget, this._metadataEditorContainer!, {
@@ -265,7 +268,10 @@ abstract class AbstractCellRenderer extends Disposable {
265268
}, {});
266269

267270
const mode = this.modeService.create('json');
268-
const originalMetadataSource = this._getFormatedJSON(this.cell.original!.metadata || {});
271+
const originalMetadataSource = this._getFormatedJSON(
272+
this.cell.type === 'insert'
273+
? this.cell.modified!.metadata || {}
274+
: this.cell.original!.metadata || {});
269275
const metadataModel = this.modelService.createModel(originalMetadataSource, mode, undefined, true);
270276
this._metadataEditor.setModel(metadataModel);
271277

@@ -409,11 +415,7 @@ export class DeletedCell extends AbstractCellRenderer {
409415
height: editorHeight
410416
}
411417
}, {});
412-
413-
if (this._diagonalFill) {
414-
this._layoutInfo.editorHeight = editorHeight;
415-
// this._diagonalFill.style.height = `${this._diffEditorContainer.clientHeight}px`;
416-
}
418+
this._layoutInfo.editorHeight = editorHeight;
417419

418420
this._register(this._editor.onDidContentSizeChange((e) => {
419421
if (e.contentHeightChanged) {
@@ -453,10 +455,6 @@ export class DeletedCell extends AbstractCellRenderer {
453455
});
454456
}
455457

456-
if (this._diagonalFill) {
457-
// this._diagonalFill.style.height = `${this._diffEditorContainer.clientHeight}px`;
458-
}
459-
460458
this.notebookEditor.layoutNotebookCell(this.cell,
461459
this._layoutInfo.editorHeight + this._layoutInfo.editorMargin + this._layoutInfo.metadataHeight + this._layoutInfo.metadataStatusHeight + this._layoutInfo.bodyMargin);
462460
}
@@ -498,10 +496,6 @@ export class InsertCell extends AbstractCellRenderer {
498496

499497
this._layoutInfo.editorHeight = editorHeight;
500498

501-
if (this._diagonalFill) {
502-
this._diagonalFill.style.height = `${this._diffEditorContainer.clientHeight}px`;
503-
}
504-
505499
this._register(this._editor.onDidContentSizeChange((e) => {
506500
if (e.contentHeightChanged) {
507501
this._layoutInfo.editorHeight = e.contentHeight;
@@ -534,16 +528,16 @@ export class InsertCell extends AbstractCellRenderer {
534528
}
535529

536530
if (state.metadataEditor || state.outerWidth) {
531+
if (this._metadataEditorContainer) {
532+
this._metadataEditorContainer.style.height = `${this._layoutInfo.metadataHeight}px`;
533+
}
534+
537535
this._metadataEditor?.layout({
538536
width: this.notebookEditor.getLayoutInfo().width - 20,
539537
height: this._layoutInfo.metadataHeight
540538
});
541539
}
542540

543-
if (this._diagonalFill) {
544-
this._diagonalFill.style.height = `${this._diffEditorContainer.clientHeight}px`;
545-
}
546-
547541
this.notebookEditor.layoutNotebookCell(this.cell,
548542
this._layoutInfo.editorHeight + this._layoutInfo.editorMargin + this._layoutInfo.metadataHeight + this._layoutInfo.metadataStatusHeight + this._layoutInfo.bodyMargin);
549543
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
margin: 8px;
2323
}
2424

25+
.notebook-text-diff-editor .cell-body.right {
26+
flex-direction: row-reverse;
27+
}
28+
2529
.notebook-text-diff-editor .cell-body .diagonal-fill {
2630
display: none;
2731
width: 50%;

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,12 @@ export class NotebookTextDiffEditor extends BaseEditor implements INotebookTextD
288288
registerThemingParticipant((theme, collector) => {
289289
const cellBorderColor = theme.getColor(notebookCellBorder);
290290
if (cellBorderColor) {
291-
collector.addRule(`.notebook-text-diff-editor .source-container { border: 1px solid ${cellBorderColor};}`);
291+
collector.addRule(`.notebook-text-diff-editor .cell-body { border: 1px solid ${cellBorderColor};}`);
292292
collector.addRule(`.notebook-text-diff-editor .metadata-editor-container {
293-
border-left: 1px solid ${cellBorderColor};
294-
border-right: 1px solid ${cellBorderColor};
295-
border-bottom: 1px solid ${cellBorderColor};
293+
border-top: 1px solid ${cellBorderColor}
296294
}`);
297295
collector.addRule(`.notebook-text-diff-editor .cell-diff-editor-container .metadata-header-container {
298-
border-left: 1px solid ${cellBorderColor};
299-
border-right: 1px solid ${cellBorderColor};
300-
border-bottom: 1px solid ${cellBorderColor};
296+
border-top: 1px solid ${cellBorderColor};
301297
}`);
302298
}
303299

0 commit comments

Comments
 (0)