@@ -21,7 +21,8 @@ public record MergeConflictSelectedChunk(
2121 double Y ,
2222 double Height ,
2323 int ConflictIndex ,
24- MergeConflictPanelType Panel
24+ MergeConflictPanelType Panel ,
25+ bool IsResolved
2526 ) ;
2627
2728 // Represents a single conflict region with its original content and panel positions
@@ -39,6 +40,14 @@ public class ConflictRegion
3940
4041 // Content chosen when resolved (null = unresolved, empty list = deleted)
4142 public List < string > ResolvedContent { get ; set ; } = null ;
43+
44+ // Real markers from the file
45+ public string StartMarker { get ; set ; } = "<<<<<<<" ;
46+ public string SeparatorMarker { get ; set ; } = "=======" ;
47+ public string EndMarker { get ; set ; } = ">>>>>>>" ;
48+
49+ // Track the type of resolution
50+ public Models . ConflictResolution ResolutionType { get ; set ; } = Models . ConflictResolution . None ;
4251 }
4352
4453 public class MergeConflictEditor : ObservableObject
@@ -251,6 +260,8 @@ private void ParseOriginalConflicts(string content)
251260 if ( line . StartsWith ( "<<<<<<<" , StringComparison . Ordinal ) )
252261 {
253262 var region = new ConflictRegion { StartLineInOriginal = i } ;
263+ // Capture the start marker (e.g., "<<<<<<< HEAD")
264+ region . StartMarker = line ;
254265 i ++ ;
255266
256267 // Collect ours content
@@ -270,9 +281,12 @@ private void ParseOriginalConflicts(string content)
270281 i ++ ;
271282 }
272283
273- // Skip separator
284+ // Capture separator marker
274285 if ( i < lines . Length && lines [ i ] . StartsWith ( "=======" , StringComparison . Ordinal ) )
286+ {
287+ region . SeparatorMarker = lines [ i ] ;
275288 i ++ ;
289+ }
276290
277291 // Collect theirs content
278292 while ( i < lines . Length && ! lines [ i ] . StartsWith ( ">>>>>>>" , StringComparison . Ordinal ) )
@@ -281,9 +295,10 @@ private void ParseOriginalConflicts(string content)
281295 i ++ ;
282296 }
283297
284- // End marker
298+ // Capture end marker (e.g., ">>>>>>> feature-branch")
285299 if ( i < lines . Length && lines [ i ] . StartsWith ( ">>>>>>>" , StringComparison . Ordinal ) )
286300 {
301+ region . EndMarker = lines [ i ] ;
287302 region . EndLineInOriginal = i ;
288303 i ++ ;
289304 }
@@ -446,11 +461,18 @@ private void BuildAlignedResultPanel()
446461
447462 if ( currentRegion . ResolvedContent != null )
448463 {
449- // Resolved - show resolved content + padding
464+ // Resolved - show resolved content with color based on resolution type
465+ var lineType = currentRegion . ResolutionType switch
466+ {
467+ Models . ConflictResolution . UseOurs => Models . TextDiffLineType . Deleted , // Mine color
468+ Models . ConflictResolution . UseTheirs => Models . TextDiffLineType . Added , // Theirs color
469+ _ => Models . TextDiffLineType . Normal
470+ } ;
471+
450472 foreach ( var line in currentRegion . ResolvedContent )
451473 {
452474 resultLines . Add ( new Models . TextDiffLine (
453- Models . TextDiffLineType . Normal , line , resultLineNumber , resultLineNumber ) ) ;
475+ lineType , line , resultLineNumber , resultLineNumber ) ) ;
454476 resultLineNumber ++ ;
455477 }
456478 // Pad with empty lines to match Mine/Theirs panel height
@@ -461,11 +483,11 @@ private void BuildAlignedResultPanel()
461483 else
462484 {
463485 // Unresolved - show conflict markers with content, aligned with Mine/Theirs
464- // First line: start marker placeholder (matches <<<<<< line )
465- resultLines . Add ( new Models . TextDiffLine ( Models . TextDiffLineType . Indicator , "<<<<<<< (unresolved)" , 0 , 0 ) ) ;
486+ // First line: start marker (use real marker from file )
487+ resultLines . Add ( new Models . TextDiffLine ( Models . TextDiffLineType . Indicator , currentRegion . StartMarker , 0 , 0 ) ) ;
466488
467- // Second line: separator placeholder (matches ======= line)
468- resultLines . Add ( new Models . TextDiffLine ( Models . TextDiffLineType . Indicator , "=======" , 0 , 0 ) ) ;
489+ // Second line: separator marker
490+ resultLines . Add ( new Models . TextDiffLine ( Models . TextDiffLineType . Indicator , currentRegion . SeparatorMarker , 0 , 0 ) ) ;
469491
470492 // Mine content lines (matches the deleted lines in Ours panel)
471493 foreach ( var line in currentRegion . OursContent )
@@ -481,8 +503,8 @@ private void BuildAlignedResultPanel()
481503 Models . TextDiffLineType . Added , line , 0 , resultLineNumber ++ ) ) ;
482504 }
483505
484- // End marker placeholder (matches >>>>>>> line )
485- resultLines . Add ( new Models . TextDiffLine ( Models . TextDiffLineType . Indicator , ">>>>>>> (unresolved)" , 0 , 0 ) ) ;
506+ // End marker (use real marker from file )
507+ resultLines . Add ( new Models . TextDiffLine ( Models . TextDiffLineType . Indicator , currentRegion . EndMarker , 0 , 0 ) ) ;
486508 }
487509
488510 currentLine = currentRegion . PanelEndLine + 1 ;
@@ -523,6 +545,7 @@ public void AcceptOurs()
523545 {
524546 region . ResolvedContent = new List < string > ( region . OursContent ) ;
525547 region . IsResolved = true ;
548+ region . ResolutionType = Models . ConflictResolution . UseOurs ;
526549 anyResolved = true ;
527550 }
528551 }
@@ -548,6 +571,7 @@ public void AcceptTheirs()
548571 {
549572 region . ResolvedContent = new List < string > ( region . TheirsContent ) ;
550573 region . IsResolved = true ;
574+ region . ResolutionType = Models . ConflictResolution . UseTheirs ;
551575 anyResolved = true ;
552576 }
553577 }
@@ -572,6 +596,7 @@ public void AcceptCurrentOurs()
572596
573597 region . ResolvedContent = new List < string > ( region . OursContent ) ;
574598 region . IsResolved = true ;
599+ region . ResolutionType = Models . ConflictResolution . UseOurs ;
575600
576601 RebuildResultContent ( ) ;
577602 BuildAlignedResultPanel ( ) ;
@@ -590,6 +615,7 @@ public void AcceptCurrentTheirs()
590615
591616 region . ResolvedContent = new List < string > ( region . TheirsContent ) ;
592617 region . IsResolved = true ;
618+ region . ResolutionType = Models . ConflictResolution . UseTheirs ;
593619
594620 RebuildResultContent ( ) ;
595621 BuildAlignedResultPanel ( ) ;
@@ -610,6 +636,7 @@ public void AcceptOursAtIndex(int conflictIndex)
610636
611637 region . ResolvedContent = new List < string > ( region . OursContent ) ;
612638 region . IsResolved = true ;
639+ region . ResolutionType = Models . ConflictResolution . UseOurs ;
613640
614641 RebuildResultContent ( ) ;
615642 BuildAlignedResultPanel ( ) ;
@@ -628,6 +655,26 @@ public void AcceptTheirsAtIndex(int conflictIndex)
628655
629656 region . ResolvedContent = new List < string > ( region . TheirsContent ) ;
630657 region . IsResolved = true ;
658+ region . ResolutionType = Models . ConflictResolution . UseTheirs ;
659+
660+ RebuildResultContent ( ) ;
661+ BuildAlignedResultPanel ( ) ;
662+ UpdateConflictInfo ( ) ;
663+ IsModified = true ;
664+ }
665+
666+ public void UndoResolutionAtIndex ( int conflictIndex )
667+ {
668+ if ( conflictIndex < 0 || conflictIndex >= _conflictRegions . Count )
669+ return ;
670+
671+ var region = _conflictRegions [ conflictIndex ] ;
672+ if ( ! region . IsResolved )
673+ return ;
674+
675+ region . ResolvedContent = null ;
676+ region . IsResolved = false ;
677+ region . ResolutionType = Models . ConflictResolution . None ;
631678
632679 RebuildResultContent ( ) ;
633680 BuildAlignedResultPanel ( ) ;
0 commit comments