@@ -9,7 +9,7 @@ import { IconLabel } from 'vs/base/browser/ui/iconLabel/iconLabel';
9
9
import { Orientation , Sizing } from 'vs/base/browser/ui/splitview/splitview' ;
10
10
import { Toggle } from 'vs/base/browser/ui/toggle/toggle' ;
11
11
import { IAction } from 'vs/base/common/actions' ;
12
- import { findLast } from 'vs/base/common/arrays' ;
12
+ import { CompareResult , findLast } from 'vs/base/common/arrays' ;
13
13
import { CancellationToken } from 'vs/base/common/cancellation' ;
14
14
import { Codicon } from 'vs/base/common/codicons' ;
15
15
import { Color } from 'vs/base/common/color' ;
@@ -48,7 +48,7 @@ import { autorun, autorunWithStore, derivedObservable, IObservable, ITransaction
48
48
import { MergeEditorInput } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput' ;
49
49
import { MergeEditorModel } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorModel' ;
50
50
import { LineRange , ModifiedBaseRange } from 'vs/workbench/contrib/mergeEditor/browser/model' ;
51
- import { applyObservableDecorations , n , ReentrancyBarrier , setStyle } from 'vs/workbench/contrib/mergeEditor/browser/utils' ;
51
+ import { applyObservableDecorations , join , n , ReentrancyBarrier , setStyle } from 'vs/workbench/contrib/mergeEditor/browser/utils' ;
52
52
import { settingsSashBorder } from 'vs/workbench/contrib/preferences/common/settingsEditorColorRegistry' ;
53
53
import { IEditorGroup , IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
54
54
import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
@@ -432,19 +432,6 @@ function synchronizeScrolling(scrollingEditor: CodeEditorWidget, targetEditor: C
432
432
433
433
const factor = Math . min ( ( scrollingEditor . getScrollTop ( ) - sourceStartTopPx ) / ( sourceEndPx - sourceStartTopPx ) , 1 ) ;
434
434
const resultScrollPosition = resultStartTopPx + ( resultEndPx - resultStartTopPx ) * factor ;
435
- /*
436
- console.log({
437
- topLineNumber,
438
- sourceRange: sourceRange.toString(),
439
- targetRange: targetRange.toString(),
440
- // resultStartTopPx,
441
- // resultEndPx,
442
- // sourceStartTopPx,
443
- // sourceEndPx,
444
- factor,
445
- resultScrollPosition,
446
- top: scrollingEditor.getScrollTop(),
447
- });*/
448
435
449
436
targetEditor . setScrollTop ( resultScrollPosition , ScrollType . Immediate ) ;
450
437
}
@@ -541,7 +528,7 @@ class InputCodeEditorView extends CodeEditorView {
541
528
range : new Range ( range . startLineNumber , 1 , range . endLineNumberExclusive - 1 , 1 ) ,
542
529
options : {
543
530
isWholeLine : true ,
544
- className : ' merge-base-range-projection' ,
531
+ className : ` merge-editor-modified- base-range-input ${ this . inputNumber } ` ,
545
532
description : 'Base Range Projection'
546
533
}
547
534
} ) ;
@@ -666,18 +653,47 @@ class ResultCodeEditorView extends CodeEditorView {
666
653
return [ ] ;
667
654
}
668
655
const result = new Array < IModelDeltaDecoration > ( ) ;
669
- for ( const m of model . resultDiffs . read ( reader ) ) {
670
- const range = m . modifiedRange ;
671
- if ( ! range . isEmpty ) {
672
- result . push ( {
673
- range : new Range ( range . startLineNumber , 1 , range . endLineNumberExclusive - 1 , 1 ) ,
674
- options : {
675
- isWholeLine : true ,
676
- // TODO
677
- className : 'merge-base-range-projection' ,
678
- description : 'Result Diff'
679
- }
680
- } ) ;
656
+
657
+ const baseRangeWithStoreAndTouchingDiffs = join (
658
+ model . modifiedBaseRanges . read ( reader ) ,
659
+ model . resultDiffs . read ( reader ) ,
660
+ ( baseRange , diff ) =>
661
+ baseRange . baseRange . touches ( diff . originalRange )
662
+ ? CompareResult . neitherLessOrGreaterThan
663
+ : LineRange . compareByStart (
664
+ baseRange . baseRange ,
665
+ diff . originalRange
666
+ )
667
+ ) ;
668
+
669
+ for ( const m of baseRangeWithStoreAndTouchingDiffs ) {
670
+ for ( const r of m . rights ) {
671
+ const range = r . modifiedRange ;
672
+
673
+ const state = m . left ? model . getState ( m . left ) . read ( reader ) : undefined ;
674
+
675
+ if ( ! range . isEmpty ) {
676
+ result . push ( {
677
+ range : new Range ( range . startLineNumber , 1 , range . endLineNumberExclusive - 1 , 1 ) ,
678
+ options : {
679
+ isWholeLine : true ,
680
+ // TODO
681
+
682
+ className : ( ( ) => {
683
+ if ( state ) {
684
+ if ( state . input1 && ! state . input2 ) {
685
+ return 'merge-editor-modified-base-range-input1' ;
686
+ }
687
+ if ( state . input2 && ! state . input1 ) {
688
+ return 'merge-editor-modified-base-range-input2' ;
689
+ }
690
+ }
691
+ return 'merge-editor-modified-base-range-combination' ;
692
+ } ) ( ) ,
693
+ description : 'Result Diff'
694
+ }
695
+ } ) ;
696
+ }
681
697
}
682
698
}
683
699
return result ;
0 commit comments