@@ -7,8 +7,8 @@ import * as DOM from 'vs/base/browser/dom';
7
7
import { Disposable , DisposableStore , IDisposable } from 'vs/base/common/lifecycle' ;
8
8
import { Schemas } from 'vs/base/common/network' ;
9
9
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
10
- import { DiffElementViewModelBase , getFormattedMetadataJSON , getFormattedOutputJSON , OutputComparison , outputEqual , OUTPUT_EDITOR_HEIGHT_MAGIC , PropertyFoldingState , SideBySideDiffElementViewModel , SingleSideDiffElementViewModel } from 'vs/workbench/contrib/notebook/browser/diff/diffElementViewModel' ;
11
- import { CellDiffSideBySideRenderTemplate , CellDiffSingleSideRenderTemplate , DiffSide , DIFF_CELL_MARGIN , INotebookTextDiffEditor , NOTEBOOK_DIFF_CELL_INPUT , NOTEBOOK_DIFF_CELL_PROPERTY , NOTEBOOK_DIFF_CELL_PROPERTY_EXPANDED } from 'vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser' ;
10
+ import { DiffElementCellViewModelBase , getFormattedMetadataJSON , getFormattedOutputJSON , OutputComparison , outputEqual , OUTPUT_EDITOR_HEIGHT_MAGIC , PropertyFoldingState , SideBySideDiffElementViewModel , SingleSideDiffElementViewModel , DiffElementPlaceholderViewModel } from 'vs/workbench/contrib/notebook/browser/diff/diffElementViewModel' ;
11
+ import { CellDiffSideBySideRenderTemplate , CellDiffSingleSideRenderTemplate , DiffSide , DIFF_CELL_MARGIN , INotebookTextDiffEditor , NOTEBOOK_DIFF_CELL_INPUT , NOTEBOOK_DIFF_CELL_PROPERTY , NOTEBOOK_DIFF_CELL_PROPERTY_EXPANDED , CellDiffPlaceholderRenderTemplate , IDiffCellMarginOverlay } from 'vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser' ;
12
12
import { CodeEditorWidget , ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditor/codeEditorWidget' ;
13
13
import { IModelService } from 'vs/editor/common/services/model' ;
14
14
import { ILanguageService } from 'vs/editor/common/languages/language' ;
@@ -31,7 +31,7 @@ import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestCont
31
31
import { MenuPreventer } from 'vs/workbench/contrib/codeEditor/browser/menuPreventer' ;
32
32
import { SelectionClipboardContributionID } from 'vs/workbench/contrib/codeEditor/browser/selectionClipboard' ;
33
33
import { TabCompletionController } from 'vs/workbench/contrib/snippets/browser/tabCompletion' ;
34
- import { renderIcon } from 'vs/base/browser/ui/iconLabel/iconLabels' ;
34
+ import { renderIcon , renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels' ;
35
35
import * as editorCommon from 'vs/editor/common/editorCommon' ;
36
36
import { ITextModelService } from 'vs/editor/common/services/resolverService' ;
37
37
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
@@ -44,6 +44,8 @@ import { IAccessibilityService } from 'vs/platform/accessibility/common/accessib
44
44
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditor/diffEditorWidget' ;
45
45
import { ICommandService } from 'vs/platform/commands/common/commands' ;
46
46
import { DiffNestedCellViewModel } from 'vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel' ;
47
+ import { localize } from 'vs/nls' ;
48
+ import { Emitter } from 'vs/base/common/event' ;
47
49
48
50
export function getOptimizedNestedCodeEditorWidgetOptions ( ) : ICodeEditorWidgetOptions {
49
51
return {
@@ -59,6 +61,29 @@ export function getOptimizedNestedCodeEditorWidgetOptions(): ICodeEditorWidgetOp
59
61
} ;
60
62
}
61
63
64
+ export class CellDiffPlaceholderElement extends Disposable {
65
+ constructor (
66
+ placeholder : DiffElementPlaceholderViewModel ,
67
+ templateData : CellDiffPlaceholderRenderTemplate ,
68
+ ) {
69
+ super ( ) ;
70
+ templateData . body . classList . remove ( 'left' , 'right' , 'full' ) ;
71
+ const text = ( placeholder . hiddenCells . length === 1 ) ?
72
+ localize ( 'hiddenCell' , '{0} hidden cell' , placeholder . hiddenCells . length ) :
73
+ localize ( 'hiddenCells' , '{0} hidden cells' , placeholder . hiddenCells . length ) ;
74
+ templateData . placeholder . innerText = text ;
75
+
76
+ this . _register ( DOM . addDisposableListener ( templateData . placeholder , 'dblclick' , ( e : MouseEvent ) => {
77
+ if ( e . button !== 0 ) {
78
+ return ;
79
+ }
80
+ e . preventDefault ( ) ;
81
+ placeholder . showHiddenCells ( ) ;
82
+ } ) ) ;
83
+ this . _register ( templateData . marginOverlay . onAction ( ( ) => placeholder . showHiddenCells ( ) ) ) ;
84
+ templateData . marginOverlay . show ( ) ;
85
+ }
86
+ }
62
87
63
88
class PropertyHeader extends Disposable {
64
89
protected _foldingIndicator ! : HTMLElement ;
@@ -69,14 +94,14 @@ class PropertyHeader extends Disposable {
69
94
protected _propertyExpanded ?: IContextKey < boolean > ;
70
95
71
96
constructor (
72
- readonly cell : DiffElementViewModelBase ,
97
+ readonly cell : DiffElementCellViewModelBase ,
73
98
readonly propertyHeaderContainer : HTMLElement ,
74
99
readonly notebookEditor : INotebookTextDiffEditor ,
75
100
readonly accessor : {
76
101
updateInfoRendering : ( renderOutput : boolean ) => void ;
77
- checkIfModified : ( cell : DiffElementViewModelBase ) => false | { reason : string | undefined } ;
78
- getFoldingState : ( cell : DiffElementViewModelBase ) => PropertyFoldingState ;
79
- updateFoldingState : ( cell : DiffElementViewModelBase , newState : PropertyFoldingState ) => void ;
102
+ checkIfModified : ( cell : DiffElementCellViewModelBase ) => false | { reason : string | undefined } ;
103
+ getFoldingState : ( cell : DiffElementCellViewModelBase ) => PropertyFoldingState ;
104
+ updateFoldingState : ( cell : DiffElementCellViewModelBase , newState : PropertyFoldingState ) => void ;
80
105
unChangedLabel : string ;
81
106
changedLabel : string ;
82
107
prefix : string ;
@@ -271,7 +296,7 @@ abstract class AbstractElementRenderer extends Disposable {
271
296
272
297
constructor (
273
298
readonly notebookEditor : INotebookTextDiffEditor ,
274
- readonly cell : DiffElementViewModelBase ,
299
+ readonly cell : DiffElementCellViewModelBase ,
275
300
readonly templateData : CellDiffSingleSideRenderTemplate | CellDiffSideBySideRenderTemplate ,
276
301
readonly style : 'left' | 'right' | 'full' ,
277
302
protected readonly instantiationService : IInstantiationService ,
@@ -1361,6 +1386,15 @@ export class ModifiedElement extends AbstractElementRenderer {
1361
1386
container . classList . remove ( 'inserted' , 'removed' ) ;
1362
1387
}
1363
1388
1389
+ override buildBody ( ) : void {
1390
+ super . buildBody ( ) ;
1391
+ if ( this . cell . displayIconToHideUnmodifiedCells ) {
1392
+ this . _register ( this . templateData . marginOverlay . onAction ( ( ) => this . cell . hideUnchangedCells ( ) ) ) ;
1393
+ this . templateData . marginOverlay . show ( ) ;
1394
+ } else {
1395
+ this . templateData . marginOverlay . hide ( ) ;
1396
+ }
1397
+ }
1364
1398
_disposeMetadata ( ) {
1365
1399
this . cell . metadataStatusHeight = 0 ;
1366
1400
this . cell . metadataHeight = 0 ;
@@ -1790,3 +1824,78 @@ export class ModifiedElement extends AbstractElementRenderer {
1790
1824
super . dispose ( ) ;
1791
1825
}
1792
1826
}
1827
+
1828
+
1829
+ export class CollapsedCellOverlayWidget extends Disposable implements IDiffCellMarginOverlay {
1830
+ private readonly _nodes = DOM . h ( 'div.diff-hidden-cells' , [
1831
+ DOM . h ( 'div.center@content' , { style : { display : 'flex' } } , [
1832
+ DOM . $ ( 'a' , {
1833
+ title : localize ( 'showUnchangedCells' , 'Show Unchanged Cells' ) ,
1834
+ role : 'button' ,
1835
+ onclick : ( ) => { this . _action . fire ( ) ; }
1836
+ } ,
1837
+ ...renderLabelWithIcons ( '$(unfold)' ) ) ]
1838
+ ) ,
1839
+ ] ) ;
1840
+
1841
+ private readonly _action = this . _register ( new Emitter < void > ( ) ) ;
1842
+ public readonly onAction = this . _action . event ;
1843
+ constructor (
1844
+ private readonly container : HTMLElement
1845
+ ) {
1846
+ super ( ) ;
1847
+
1848
+ this . _nodes . root . style . display = 'none' ;
1849
+ container . appendChild ( this . _nodes . root ) ;
1850
+ }
1851
+ public show ( ) {
1852
+ this . _nodes . root . style . display = 'block' ;
1853
+ }
1854
+ public hide ( ) {
1855
+ this . _nodes . root . style . display = 'none' ;
1856
+ }
1857
+ public override dispose ( ) {
1858
+ this . hide ( ) ;
1859
+ this . container . removeChild ( this . _nodes . root ) ;
1860
+ DOM . reset ( this . _nodes . root ) ;
1861
+ super . dispose ( ) ;
1862
+ }
1863
+ }
1864
+
1865
+ export class UnchangedCellOverlayWidget extends Disposable implements IDiffCellMarginOverlay {
1866
+ private readonly _nodes = DOM . h ( 'div.diff-hidden-cells' , [
1867
+ DOM . h ( 'div.center@content' , { style : { display : 'flex' } } , [
1868
+ DOM . $ ( 'a' , {
1869
+ title : localize ( 'hideUnchangedCells' , 'Hide Unchanged Cells' ) ,
1870
+ role : 'button' ,
1871
+ onclick : ( ) => { this . _action . fire ( ) ; }
1872
+ } ,
1873
+ ...renderLabelWithIcons ( '$(fold)' )
1874
+ ) ,
1875
+ ]
1876
+ ) ,
1877
+ ] ) ;
1878
+
1879
+ private readonly _action = this . _register ( new Emitter < void > ( ) ) ;
1880
+ public readonly onAction = this . _action . event ;
1881
+ constructor (
1882
+ private readonly container : HTMLElement
1883
+ ) {
1884
+ super ( ) ;
1885
+
1886
+ this . _nodes . root . style . display = 'none' ;
1887
+ container . appendChild ( this . _nodes . root ) ;
1888
+ }
1889
+ public show ( ) {
1890
+ this . _nodes . root . style . display = 'block' ;
1891
+ }
1892
+ public hide ( ) {
1893
+ this . _nodes . root . style . display = 'none' ;
1894
+ }
1895
+ public override dispose ( ) {
1896
+ this . hide ( ) ;
1897
+ this . container . removeChild ( this . _nodes . root ) ;
1898
+ DOM . reset ( this . _nodes . root ) ;
1899
+ super . dispose ( ) ;
1900
+ }
1901
+ }
0 commit comments