@@ -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' ;
@@ -47,7 +47,7 @@ import { autorun, autorunWithStore, derivedObservable, IObservable, ITransaction
47
47
import { MergeEditorInput } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput' ;
48
48
import { MergeEditorModel } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorModel' ;
49
49
import { LineRange , ModifiedBaseRange } from 'vs/workbench/contrib/mergeEditor/browser/model' ;
50
- import { applyObservableDecorations , n , ReentrancyBarrier , setStyle } from 'vs/workbench/contrib/mergeEditor/browser/utils' ;
50
+ import { applyObservableDecorations , join , n , ReentrancyBarrier , setStyle } from 'vs/workbench/contrib/mergeEditor/browser/utils' ;
51
51
import { settingsSashBorder } from 'vs/workbench/contrib/preferences/common/settingsEditorColorRegistry' ;
52
52
import { EditorGutter , IGutterItemInfo , IGutterItemView } from './editorGutter' ;
53
53
@@ -354,19 +354,6 @@ function synchronizeScrolling(scrollingEditor: CodeEditorWidget, targetEditor: C
354
354
355
355
const factor = Math . min ( ( scrollingEditor . getScrollTop ( ) - sourceStartTopPx ) / ( sourceEndPx - sourceStartTopPx ) , 1 ) ;
356
356
const resultScrollPosition = resultStartTopPx + ( resultEndPx - resultStartTopPx ) * factor ;
357
- /*
358
- console.log({
359
- topLineNumber,
360
- sourceRange: sourceRange.toString(),
361
- targetRange: targetRange.toString(),
362
- // resultStartTopPx,
363
- // resultEndPx,
364
- // sourceStartTopPx,
365
- // sourceEndPx,
366
- factor,
367
- resultScrollPosition,
368
- top: scrollingEditor.getScrollTop(),
369
- });*/
370
357
371
358
targetEditor . setScrollTop ( resultScrollPosition , ScrollType . Immediate ) ;
372
359
}
@@ -463,7 +450,7 @@ class InputCodeEditorView extends CodeEditorView {
463
450
range : new Range ( range . startLineNumber , 1 , range . endLineNumberExclusive - 1 , 1 ) ,
464
451
options : {
465
452
isWholeLine : true ,
466
- className : ' merge-base-range-projection' ,
453
+ className : ` merge-editor-modified- base-range-input ${ this . inputNumber } ` ,
467
454
description : 'Base Range Projection'
468
455
}
469
456
} ) ;
@@ -589,18 +576,47 @@ class ResultCodeEditorView extends CodeEditorView {
589
576
return [ ] ;
590
577
}
591
578
const result = new Array < IModelDeltaDecoration > ( ) ;
592
- for ( const m of model . resultDiffs . read ( reader ) ) {
593
- const range = m . modifiedRange ;
594
- if ( ! range . isEmpty ) {
595
- result . push ( {
596
- range : new Range ( range . startLineNumber , 1 , range . endLineNumberExclusive - 1 , 1 ) ,
597
- options : {
598
- isWholeLine : true ,
599
- // TODO
600
- className : 'merge-base-range-projection' ,
601
- description : 'Result Diff'
602
- }
603
- } ) ;
579
+
580
+ const baseRangeWithStoreAndTouchingDiffs = join (
581
+ model . modifiedBaseRanges . read ( reader ) ,
582
+ model . resultDiffs . read ( reader ) ,
583
+ ( baseRange , diff ) =>
584
+ baseRange . baseRange . touches ( diff . originalRange )
585
+ ? CompareResult . neitherLessOrGreaterThan
586
+ : LineRange . compareByStart (
587
+ baseRange . baseRange ,
588
+ diff . originalRange
589
+ )
590
+ ) ;
591
+
592
+ for ( const m of baseRangeWithStoreAndTouchingDiffs ) {
593
+ for ( const r of m . rights ) {
594
+ const range = r . modifiedRange ;
595
+
596
+ const state = m . left ? model . getState ( m . left ) . read ( reader ) : undefined ;
597
+
598
+ if ( ! range . isEmpty ) {
599
+ result . push ( {
600
+ range : new Range ( range . startLineNumber , 1 , range . endLineNumberExclusive - 1 , 1 ) ,
601
+ options : {
602
+ isWholeLine : true ,
603
+ // TODO
604
+
605
+ className : ( ( ) => {
606
+ if ( state ) {
607
+ if ( state . input1 && ! state . input2 ) {
608
+ return 'merge-editor-modified-base-range-input1' ;
609
+ }
610
+ if ( state . input2 && ! state . input1 ) {
611
+ return 'merge-editor-modified-base-range-input2' ;
612
+ }
613
+ }
614
+ return 'merge-editor-modified-base-range-combination' ;
615
+ } ) ( ) ,
616
+ description : 'Result Diff'
617
+ }
618
+ } ) ;
619
+ }
604
620
}
605
621
}
606
622
return result ;
0 commit comments