jpnurmi / item_selector

Compare ec5a794 ... +3 ... 1854fa8

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 69 files from the diff.
Other files ignored by Codecov
README.md has changed.

@@ -29,6 +29,7 @@
Loading
29 29
// Thanks to Hugo Passos.
30 30
//
31 31
import 'dart:collection';
32 +
import 'dart:math';
32 33
33 34
import 'package:interval_tree/interval_tree.dart';
34 35
@@ -73,6 +74,10 @@
Loading
73 74
    }
74 75
  }
75 76
77 +
  /// Creates a copy of the [other] selection.
78 +
  factory ItemSelection.copy(ItemSelection other) =>
79 +
      ItemSelection()..addAll(other);
80 +
76 81
  /// Returns `true` if this selection is empty.
77 82
  bool get isEmpty => _tree.isEmpty;
78 83
@@ -106,16 +111,40 @@
Loading
106 111
    _tree.add([start, end]);
107 112
  }
108 113
114 +
  /// Adds all selection ranges to this selection,
115 +
  /// that are in the [other] selection.
116 +
  void addAll(ItemSelection other) {
117 +
    for (final iv in other._tree) {
118 +
      add(iv.start, iv.end);
119 +
    }
120 +
  }
121 +
109 122
  /// Removes the selection range from [start] to [end].
110 123
  void remove(int start, [int end]) {
111 -
    end ??= start;
112 124
    if (_tree.isEmpty) return;
113 -
    final removal = IntervalTree([start - 1, end + 1]);
114 -
    removal.removeAll(_tree.intersection(removal));
115 -
    for (int i = start; i <= end; ++i) {
116 -
      notifyListeners(i, false);
125 +
    start = max(start, first);
126 +
    end = min(end ?? start, last);
127 +
    final removal = _tree.intersection(IntervalTree([start, end]));
128 +
    for (final range in removal) {
129 +
      for (int i = range.start; i <= range.end; ++i) {
130 +
        notifyListeners(i, false);
131 +
      }
117 132
    }
133 +
    final startAtBounds = _tree.contains([start - 1, start - 1]) &&
134 +
        !_tree.contains([start - 2, start - 2]);
135 +
    final endAtBounds = _tree.contains([end + 1, end + 1]) &&
136 +
        !_tree.contains([end + 2, end + 2]);
118 137
    _tree.remove([start - 1, end + 1]);
138 +
    if (startAtBounds) _tree.add([start - 1, start - 1]);
139 +
    if (endAtBounds) _tree.add([end + 1, end + 1]);
140 +
  }
141 +
142 +
  /// Removes all selection ranges from this selection,
143 +
  /// that are in the [other] selection.
144 +
  void removeAll(ItemSelection other) {
145 +
    for (final iv in other._tree) {
146 +
      remove(iv.start, iv.end);
147 +
    }
119 148
  }
120 149
121 150
  /// Replaces the existing selection with a selection range from [start] to

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
lib/src 0.39% 94.35%
Project Totals (6 files) 94.35%
Loading