@@ -16,7 +16,7 @@ import { LineRange } from 'vs/workbench/contrib/mergeEditor/browser/model/lineRa
16
16
import { DetailedLineRangeMapping , DocumentLineRangeMap , DocumentRangeMap , LineRangeMapping } from 'vs/workbench/contrib/mergeEditor/browser/model/mapping' ;
17
17
import { TextModelDiffChangeReason , TextModelDiffs , TextModelDiffState } from 'vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs' ;
18
18
import { leftJoin } from 'vs/workbench/contrib/mergeEditor/browser/utils' ;
19
- import { ModifiedBaseRange , ModifiedBaseRangeState } from './modifiedBaseRange' ;
19
+ import { ModifiedBaseRange , ModifiedBaseRangeState , ModifiedBaseRangeStateKind } from './modifiedBaseRange' ;
20
20
21
21
export interface InputData {
22
22
readonly textModel : ITextModel ;
@@ -41,7 +41,7 @@ export class MergeEditorModel extends EditorModel {
41
41
this . modifiedBaseRanges . read ( reader ) . map ( ( s ) => [
42
42
s ,
43
43
{
44
- accepted : observableValue ( `BaseRangeState${ s . baseRange } ` , ModifiedBaseRangeState . default ) ,
44
+ accepted : observableValue ( `BaseRangeState${ s . baseRange } ` , ModifiedBaseRangeState . base ) ,
45
45
handled : observableValue ( `BaseRangeHandledState${ s . baseRange } ` , false ) ,
46
46
}
47
47
] )
@@ -105,7 +105,7 @@ export class MergeEditorModel extends EditorModel {
105
105
shouldRecomputeHandledFromAccepted = false ;
106
106
for ( const [ _range , observableState ] of states ) {
107
107
const state = observableState . accepted . get ( ) ;
108
- observableState . handled . set ( ! ( state . isEmpty || state . conflicting ) , tx ) ;
108
+ observableState . handled . set ( ! ( state . kind === ModifiedBaseRangeStateKind . base || state . kind === ModifiedBaseRangeStateKind . unrecognized ) , tx ) ;
109
109
}
110
110
}
111
111
} ) ;
@@ -132,13 +132,13 @@ export class MergeEditorModel extends EditorModel {
132
132
let newState : ModifiedBaseRangeState ;
133
133
let handled = false ;
134
134
if ( range . input1Diffs . length === 0 ) {
135
- newState = ModifiedBaseRangeState . default . withInput2 ( true ) ;
135
+ newState = ModifiedBaseRangeState . base . withInputValue ( 2 , true ) ;
136
136
handled = true ;
137
137
} else if ( range . input2Diffs . length === 0 ) {
138
- newState = ModifiedBaseRangeState . default . withInput1 ( true ) ;
138
+ newState = ModifiedBaseRangeState . base . withInputValue ( 1 , true ) ;
139
139
handled = true ;
140
140
} else {
141
- newState = ModifiedBaseRangeState . default ;
141
+ newState = ModifiedBaseRangeState . base ;
142
142
handled = false ;
143
143
}
144
144
@@ -335,7 +335,7 @@ export class MergeEditorModel extends EditorModel {
335
335
336
336
private computeState ( baseRange : ModifiedBaseRange , conflictingDiffs : DetailedLineRangeMapping [ ] ) : ModifiedBaseRangeState {
337
337
if ( conflictingDiffs . length === 0 ) {
338
- return ModifiedBaseRangeState . default ;
338
+ return ModifiedBaseRangeState . base ;
339
339
}
340
340
const conflictingEdits = conflictingDiffs . map ( ( d ) => d . getLineEdit ( ) ) ;
341
341
@@ -348,15 +348,15 @@ export class MergeEditorModel extends EditorModel {
348
348
}
349
349
350
350
if ( editsAgreeWithDiffs ( baseRange . input1Diffs ) ) {
351
- return ModifiedBaseRangeState . default . withInput1 ( true ) ;
351
+ return ModifiedBaseRangeState . base . withInputValue ( 1 , true ) ;
352
352
}
353
353
if ( editsAgreeWithDiffs ( baseRange . input2Diffs ) ) {
354
- return ModifiedBaseRangeState . default . withInput2 ( true ) ;
354
+ return ModifiedBaseRangeState . base . withInputValue ( 2 , true ) ;
355
355
}
356
356
357
357
const states = [
358
- ModifiedBaseRangeState . default . withInput1 ( true ) . withInput2 ( true ) ,
359
- ModifiedBaseRangeState . default . withInput2 ( true ) . withInput1 ( true ) ,
358
+ ModifiedBaseRangeState . base . withInputValue ( 1 , true ) . withInputValue ( 2 , true ) ,
359
+ ModifiedBaseRangeState . base . withInputValue ( 2 , true ) . withInputValue ( 1 , true ) ,
360
360
] ;
361
361
362
362
for ( const s of states ) {
@@ -371,7 +371,7 @@ export class MergeEditorModel extends EditorModel {
371
371
}
372
372
}
373
373
374
- return ModifiedBaseRangeState . conflicting ;
374
+ return ModifiedBaseRangeState . unrecognized ;
375
375
}
376
376
377
377
public getState ( baseRange : ModifiedBaseRange ) : IObservable < ModifiedBaseRangeState > {
@@ -429,8 +429,8 @@ export class MergeEditorModel extends EditorModel {
429
429
/** @description Reset Unknown Base Range States */
430
430
this . resultTextModel . pushStackElement ( ) ;
431
431
for ( const range of this . modifiedBaseRanges . get ( ) ) {
432
- if ( this . getState ( range ) . get ( ) . conflicting ) {
433
- this . setState ( range , ModifiedBaseRangeState . default , false , tx , false ) ;
432
+ if ( this . getState ( range ) . get ( ) . kind === ModifiedBaseRangeStateKind . unrecognized ) {
433
+ this . setState ( range , ModifiedBaseRangeState . base , false , tx , false ) ;
434
434
}
435
435
}
436
436
this . resultTextModel . pushStackElement ( ) ;
@@ -515,7 +515,7 @@ export class MergeEditorModel extends EditorModel {
515
515
resultStartLineNumber = resultRange . endLineNumberExclusive ;
516
516
517
517
outputLines . push ( '<<<<<<<' ) ;
518
- if ( state . accepted . get ( ) . conflicting ) {
518
+ if ( state . accepted . get ( ) . kind === ModifiedBaseRangeStateKind . unrecognized ) {
519
519
// to prevent loss of data, use modified result as "ours"
520
520
appendLinesToResult ( resultLines , resultRange ) ;
521
521
} else {
0 commit comments