@@ -260,6 +260,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
260
260
this . _options = validateDiffEditorOptions ( options , {
261
261
enableSplitViewResizing : true ,
262
262
renderSideBySide : true ,
263
+ renderMarginRevertIcon : true ,
263
264
maxComputationTime : 5000 ,
264
265
maxFileSize : 50 ,
265
266
ignoreTrimWhitespace : true ,
@@ -646,7 +647,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
646
647
range,
647
648
text : '' ,
648
649
} ] ) ;
649
- } else if ( change . modifiedEndLineNumber === 0 && originalContent ) {
650
+ } else if ( change . modifiedEndLineNumber === 0 && originalContent !== null ) {
650
651
// Delete change.
651
652
// To revert: insert the old content and a linebreak.
652
653
@@ -745,7 +746,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
745
746
const changed = changedDiffEditorOptions ( this . _options , newOptions ) ;
746
747
this . _options = newOptions ;
747
748
748
- const beginUpdateDecorations = ( changed . ignoreTrimWhitespace || changed . renderIndicators ) ;
749
+ const beginUpdateDecorations = ( changed . ignoreTrimWhitespace || changed . renderIndicators || changed . renderMarginRevertIcon ) ;
749
750
const beginUpdateDecorationsSoon = ( this . _isVisible && ( changed . maxComputationTime || changed . maxFileSize ) ) ;
750
751
751
752
if ( beginUpdateDecorations ) {
@@ -1143,7 +1144,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
1143
1144
const foreignOriginal = this . _originalEditorState . getForeignViewZones ( this . _originalEditor . getWhitespaces ( ) ) ;
1144
1145
const foreignModified = this . _modifiedEditorState . getForeignViewZones ( this . _modifiedEditor . getWhitespaces ( ) ) ;
1145
1146
1146
- const diffDecorations = this . _strategy . getEditorsDiffDecorations ( lineChanges , this . _options . ignoreTrimWhitespace , this . _options . renderIndicators , foreignOriginal , foreignModified ) ;
1147
+ const diffDecorations = this . _strategy . getEditorsDiffDecorations ( lineChanges , this . _options . ignoreTrimWhitespace , this . _options . renderIndicators , this . _options . renderMarginRevertIcon , foreignOriginal , foreignModified ) ;
1147
1148
1148
1149
try {
1149
1150
this . _currentlyChangingViewZones = true ;
@@ -1459,7 +1460,7 @@ abstract class DiffEditorWidgetStyle extends Disposable {
1459
1460
return hasChanges ;
1460
1461
}
1461
1462
1462
- public getEditorsDiffDecorations ( lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , originalWhitespaces : IEditorWhitespace [ ] , modifiedWhitespaces : IEditorWhitespace [ ] ) : IEditorsDiffDecorationsWithZones {
1463
+ public getEditorsDiffDecorations ( lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , renderMarginRevertIcon : boolean , originalWhitespaces : IEditorWhitespace [ ] , modifiedWhitespaces : IEditorWhitespace [ ] ) : IEditorsDiffDecorationsWithZones {
1463
1464
// Get view zones
1464
1465
modifiedWhitespaces = modifiedWhitespaces . sort ( ( a , b ) => {
1465
1466
return a . afterLineNumber - b . afterLineNumber ;
@@ -1471,7 +1472,7 @@ abstract class DiffEditorWidgetStyle extends Disposable {
1471
1472
1472
1473
// Get decorations & overview ruler zones
1473
1474
const originalDecorations = this . _getOriginalEditorDecorations ( zones , lineChanges , ignoreTrimWhitespace , renderIndicators ) ;
1474
- const modifiedDecorations = this . _getModifiedEditorDecorations ( zones , lineChanges , ignoreTrimWhitespace , renderIndicators ) ;
1475
+ const modifiedDecorations = this . _getModifiedEditorDecorations ( zones , lineChanges , ignoreTrimWhitespace , renderIndicators , renderMarginRevertIcon ) ;
1475
1476
1476
1477
return {
1477
1478
original : {
@@ -1489,7 +1490,7 @@ abstract class DiffEditorWidgetStyle extends Disposable {
1489
1490
1490
1491
protected abstract _getViewZones ( lineChanges : ILineChange [ ] , originalForeignVZ : IEditorWhitespace [ ] , modifiedForeignVZ : IEditorWhitespace [ ] , renderIndicators : boolean ) : IEditorsZones ;
1491
1492
protected abstract _getOriginalEditorDecorations ( zones : IEditorsZones , lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean ) : IEditorDiffDecorations ;
1492
- protected abstract _getModifiedEditorDecorations ( zones : IEditorsZones , lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean ) : IEditorDiffDecorations ;
1493
+ protected abstract _getModifiedEditorDecorations ( zones : IEditorsZones , lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , renderMarginRevertIcon : boolean ) : IEditorDiffDecorations ;
1493
1494
1494
1495
public abstract setEnableSplitViewResizing ( enableSplitViewResizing : boolean ) : void ;
1495
1496
public abstract layout ( ) : number ;
@@ -2031,7 +2032,7 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IVerti
2031
2032
return result ;
2032
2033
}
2033
2034
2034
- protected _getModifiedEditorDecorations ( zones : IEditorsZones , lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean ) : IEditorDiffDecorations {
2035
+ protected _getModifiedEditorDecorations ( zones : IEditorsZones , lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , renderMarginRevertIcon : boolean ) : IEditorDiffDecorations {
2035
2036
const modifiedEditor = this . _dataSource . getModifiedEditor ( ) ;
2036
2037
const overviewZoneColor = String ( this . _insertColor ) ;
2037
2038
@@ -2046,15 +2047,17 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IVerti
2046
2047
for ( const lineChange of lineChanges ) {
2047
2048
2048
2049
// Arrows for reverting changes.
2049
- if ( lineChange . modifiedEndLineNumber > 0 ) {
2050
- result . decorations . push ( {
2051
- range : new Range ( lineChange . modifiedStartLineNumber , 1 , lineChange . modifiedStartLineNumber , 1 ) ,
2052
- options : DECORATIONS . arrowRevertChange
2053
- } ) ;
2054
- } else {
2055
- const viewZone = zones . modified . find ( z => z . afterLineNumber === lineChange . modifiedStartLineNumber ) ;
2056
- if ( viewZone ) {
2057
- viewZone . marginDomNode = createViewZoneMarginArrow ( ) ;
2050
+ if ( renderMarginRevertIcon ) {
2051
+ if ( lineChange . modifiedEndLineNumber > 0 ) {
2052
+ result . decorations . push ( {
2053
+ range : new Range ( lineChange . modifiedStartLineNumber , 1 , lineChange . modifiedStartLineNumber , 1 ) ,
2054
+ options : DECORATIONS . arrowRevertChange
2055
+ } ) ;
2056
+ } else {
2057
+ const viewZone = zones . modified . find ( z => z . afterLineNumber === lineChange . modifiedStartLineNumber ) ;
2058
+ if ( viewZone ) {
2059
+ viewZone . marginDomNode = createViewZoneMarginArrow ( ) ;
2060
+ }
2058
2061
}
2059
2062
}
2060
2063
@@ -2222,7 +2225,7 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle {
2222
2225
return result ;
2223
2226
}
2224
2227
2225
- protected _getModifiedEditorDecorations ( zones : IEditorsZones , lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean ) : IEditorDiffDecorations {
2228
+ protected _getModifiedEditorDecorations ( zones : IEditorsZones , lineChanges : ILineChange [ ] , ignoreTrimWhitespace : boolean , renderIndicators : boolean , renderMarginRevertIcon : boolean ) : IEditorDiffDecorations {
2226
2229
const modifiedEditor = this . _dataSource . getModifiedEditor ( ) ;
2227
2230
const overviewZoneColor = String ( this . _insertColor ) ;
2228
2231
@@ -2641,6 +2644,7 @@ function validateDiffEditorOptions(options: Readonly<IDiffEditorOptions>, defaul
2641
2644
return {
2642
2645
enableSplitViewResizing : validateBooleanOption ( options . enableSplitViewResizing , defaults . enableSplitViewResizing ) ,
2643
2646
renderSideBySide : validateBooleanOption ( options . renderSideBySide , defaults . renderSideBySide ) ,
2647
+ renderMarginRevertIcon : validateBooleanOption ( options . renderMarginRevertIcon , defaults . renderMarginRevertIcon ) ,
2644
2648
maxComputationTime : clampedInt ( options . maxComputationTime , defaults . maxComputationTime , 0 , Constants . MAX_SAFE_SMALL_INTEGER ) ,
2645
2649
maxFileSize : clampedInt ( options . maxFileSize , defaults . maxFileSize , 0 , Constants . MAX_SAFE_SMALL_INTEGER ) ,
2646
2650
ignoreTrimWhitespace : validateBooleanOption ( options . ignoreTrimWhitespace , defaults . ignoreTrimWhitespace ) ,
@@ -2656,6 +2660,7 @@ function changedDiffEditorOptions(a: ValidDiffEditorBaseOptions, b: ValidDiffEdi
2656
2660
return {
2657
2661
enableSplitViewResizing : ( a . enableSplitViewResizing !== b . enableSplitViewResizing ) ,
2658
2662
renderSideBySide : ( a . renderSideBySide !== b . renderSideBySide ) ,
2663
+ renderMarginRevertIcon : ( a . renderMarginRevertIcon !== b . renderMarginRevertIcon ) ,
2659
2664
maxComputationTime : ( a . maxComputationTime !== b . maxComputationTime ) ,
2660
2665
maxFileSize : ( a . maxFileSize !== b . maxFileSize ) ,
2661
2666
ignoreTrimWhitespace : ( a . ignoreTrimWhitespace !== b . ignoreTrimWhitespace ) ,
0 commit comments