55
66import * as DOM from 'vs/base/browser/dom' ;
77import { 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' ;
99import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
1010import { CellDiffViewModel , MetadataFoldingState } from 'vs/workbench/contrib/notebook/browser/diff/celllDiffViewModel' ;
1111import { CellDiffRenderTemplate , CellDiffViewModelLayoutChangeEvent , INotebookTextDiffEditor } from 'vs/workbench/contrib/notebook/browser/diff/common' ;
@@ -21,7 +21,7 @@ import { NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/noteb
2121import { 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
5052const 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 }
0 commit comments