forked from akvelon/flutter-code-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhidden_range.dart
48 lines (40 loc) · 1.12 KB
/
hidden_range.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import 'package:equatable/equatable.dart';
import '../code/text_range.dart';
class HiddenRange extends NormalizedTextRange with EquatableMixin {
final int firstLine;
final int lastLine;
///Whether this range contains its first line entirely.
final bool wholeFirstLine;
const HiddenRange(
int start,
int end, {
required this.firstLine,
required this.lastLine,
required this.wholeFirstLine,
}) : assert(start >= 0, 'Start should be >= 0, $start given'),
assert(end > start, 'Range should not be empty, $start-$end given'),
assert(
lastLine >= firstLine,
'lastLine must be >= firstLine, $firstLine-$lastLine given',
),
super(start: start, end: end);
int get length => end - start;
/// Sorts by [start], then by [end].
static int sort(HiddenRange a, HiddenRange b) {
switch ((a.start - b.start).sign) {
case -1:
return -1;
case 1:
return 1;
}
return a.end - b.end;
}
@override
List<Object> get props => [
start,
end,
firstLine,
lastLine,
wholeFirstLine,
];
}