<commit_before>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;

namespace LogoFX.Core
{
    public class RangeObservableCollection<T> : ObservableCollection<T>
    {
        public RangeObservableCollection()
        {
        }

        public RangeObservableCollection(IEnumerable<T> collection)
            : base(collection)
        {
        }

        private bool _suppressNotification;

        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            if (!_suppressNotification)
                base.OnCollectionChanged(e);
        }

        public void AddRange(IEnumerable<T> list)
        {
            if (list == null)
                return;

            int initialindex = Count;

            var enumerable = list as T[] ?? list.ToArray();
            if (!enumerable.Any())
                return;

            _suppressNotification = true;
           
            foreach (var item in enumerable)
            {
                Add(item);
            }
           
            _suppressNotification = false;
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
                                                                     new List<T>(enumerable), initialindex));
        }

        public void RemoveRange(IEnumerable<T> list)
        {
            if (list == null)
                throw new ArgumentNullException("list");

            _suppressNotification = true;            
            var enumerable = list as T[] ?? list.ToArray();
            foreach (var item in enumerable)
            {
                Remove(item);
            }            
            _suppressNotification = false;
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, new List<T>(enumerable),0));
        }
    }
}<commit_msg>Fixed incorrect remove range for non-first element<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;

namespace LogoFX.Core
{
    public class RangeObservableCollection<T> : ObservableCollection<T>
    {
        public RangeObservableCollection()
        {
        }

        public RangeObservableCollection(IEnumerable<T> collection)
            : base(collection)
        {
        }

        private bool _suppressNotification;

        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            if (!_suppressNotification)
                base.OnCollectionChanged(e);
        }

        public void AddRange(IEnumerable<T> list)
        {
            if (list == null)
                return;

            int initialindex = Count;

            var enumerable = list as T[] ?? list.ToArray();
            if (!enumerable.Any())
                return;

            _suppressNotification = true;
           
            foreach (var item in enumerable)
            {
                Add(item);
            }
           
            _suppressNotification = false;
            OnPropertyChanged(new PropertyChangedEventArgs("Count"));
            OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
                                                                     new List<T>(enumerable)));
        }

        public void RemoveRange(IEnumerable<T> list)
        {
            if (list == null)
                throw new ArgumentNullException("list");

            _suppressNotification = true;            
            var enumerable = list as T[] ?? list.ToArray();
            var count = enumerable.Length;
            var index = -1;
            T singleItem = default(T);
            if (count == 1)
            {
                singleItem = enumerable[0];
                index = IndexOf(singleItem);

            }
            foreach (var item in enumerable)
            {
                Remove(item);
            }            
            _suppressNotification = false;
            OnPropertyChanged(new PropertyChangedEventArgs("Count"));
            OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
            OnCollectionChanged(count == 1
                ? new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, singleItem,
                    index)
                : new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
        }

        protected override void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (_suppressNotification == false)
            {
                base.OnPropertyChanged(e);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07648378543748725, 'fraction_numerical': 0.0010197838058331635, 'mean_word_length': 1.6666666666666667, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5923326', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1077, 'n_words': 240}