internal void MergeOutput(VisualDiffOutput otherOutput, ChangeType thisChangeType, ChangeType otherChangeType)
        {
            string[] thisTempLines = LinesToStringArray(this.RightLines);
            string[] otherTempLines = LinesToStringArray(otherOutput.RightLines);

            this.LeftLines.Clear();
            this.RightLines.Clear();

            Diff diff = new Diff(thisTempLines, otherTempLines, true, true);

            // loop through parts of the diff
            foreach (Diff.Hunk hunk in diff)
            {
                int lineMismatch = hunk.Right.Start - hunk.Left.Start;
                if (hunk.Same)
                {
                    for (int i = hunk.Right.Start; i <= hunk.Right.End; i++)
                    {
                        if (otherOutput.RightLines[i].Change != ChangeType.None)
                        {
                            //Both the user and template have changed to the same thing. Need to display this.
                            leftLines.Add(new DiffLine(otherOutput.LeftLines[i].Text, thisChangeType | otherChangeType, otherOutput.LeftLines[i].IsVirtual));
                            rightLines.Add(new DiffLine(otherTempLines[i], thisChangeType | otherChangeType));
                        }
                        else
                        {
                            leftLines.Add(new DiffLine(otherTempLines[i]));
                            rightLines.Add(new DiffLine(otherTempLines[i]));
                        }
                    }
                }
                else
                {
                    // If the left and right of the hunk both have lines, this could be a conflict.
                    if (hunk.Right.Count != 0 && hunk.Left.Count != 0)
                    {
                        ConflictRange conflictRange = new ConflictRange();
                        conflictRange.StartLineIndex = leftLines.Count;

                        for (int i = hunk.Right.Start; i <= hunk.Right.End; i++)
                        {
                            leftLines.Add(new DiffLine(otherTempLines[i], otherChangeType));
                            rightLines.Add(new DiffLine("", otherChangeType, true));
                        }
                        for (int i = hunk.Left.Start; i <= hunk.Left.End; i++)
                        {
                            leftLines.Add(new DiffLine(thisTempLines[i], thisChangeType));
                            rightLines.Add(new DiffLine("", thisChangeType, true));
                        }

                        conflictRange.EndLineIndex = leftLines.Count;
                        conflictRanges.Add(conflictRange);
                    }
                    else if (hunk.Right.Count != 0)
                    {
                        for (int i = hunk.Right.Start; i <= hunk.Right.End; i++)
                        {
                            leftLines.Add(new DiffLine("", otherChangeType, true));
                            rightLines.Add(new DiffLine(otherTempLines[i], otherChangeType));
                        }
                    }
                    else
                    {
                        for (int i = hunk.Left.Start; i <= hunk.Left.End; i++)
                        {
                            leftLines.Add(new DiffLine("", thisChangeType, true));
                            rightLines.Add(new DiffLine(thisTempLines[i], thisChangeType));
                        }
                    }

                }
            }
        }
 public bool IsLineInConflict(int lineIndex, out ConflictRange conflictRange)
 {
     foreach (ConflictRange range in conflictRanges)
     {
         if (range.StartLineIndex > lineIndex || range.EndLineIndex <= lineIndex)
             continue;
         if (range.StartLineIndex <= lineIndex && range.EndLineIndex > lineIndex)
         {
             conflictRange = range;
             return true;
         }
     }
     conflictRange = new ConflictRange();
     return false;
 }