Example #1
0
        internal EditorDiffMargin(IWpfTextView textView, UnifiedDiff unifiedDiff, IMarginCore marginCore)
            : base(textView)
        {
            ViewModel = new EditorDiffMarginViewModel(marginCore, unifiedDiff, UpdateDiffDimensions);

            UserControl = new EditorDiffMarginControl {DataContext = ViewModel, Width = MarginWidth};
        }
Example #2
0
        internal ScrollDiffMargin(IWpfTextView textView, UnifiedDiff unifiedDiff, IMarginCore marginCore, IWpfTextViewMargin containerMargin)
            : base(textView)
        {
            var scrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar);
            // ReSharper disable once SuspiciousTypeConversion.Global
            _scrollBar = (IVerticalScrollBar)scrollBarMargin;

            ViewModel = new ScrollDiffMarginViewModel(marginCore, unifiedDiff, UpdateDiffDimensions);

            UserControl = new ScrollDiffMarginControl { DataContext = ViewModel, Width = MarginWidth, MaxWidth = MarginWidth, MinWidth = MarginWidth};
        }
Example #3
0
        public async Task<Dictionary<string, UnifiedDiff>> ParseAsync()
        {
            var unifiedDiffs = new List<UnifiedDiff>();
            var lines = new List<string>();

            var unifiedDiffParser = new UnifiedDiffParser(3);

            using (var reader = File.OpenText(_diffFilePath))
            {
                var n = 0;

                string line;
                while ((line = await reader.ReadLineAsync()) != null)
                {
                    if (line.StartsWith("diff --git"))
                    {
                        var unifiedDiff = new UnifiedDiff(line);
                        if (n > 0)
                        {
                            unifiedDiffs[unifiedDiffs.Count - 1].HunkRanges.AddRange(unifiedDiffParser.Parse(lines));
                        }

                        n++;

                        unifiedDiffs.Add(unifiedDiff);

                        lines.Clear();

                        lines.Add(line);
                    }
                    else
                    {
                        lines.Add(line);
                    }
                }
            }

            return unifiedDiffs.ToDictionary(diff => _solutionDir.ToLower() + "\\" + diff.NewFile.Replace("/", "\\").ToLower());
        }