mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Fix issue where intervals where merged when they did not overlap due to a typo, also only add interval to merged list if it has overlapped and been merged (#1228)
This commit is contained in:
@@ -603,12 +603,13 @@ class ReplacementTextEditingController extends TextEditingController {
|
||||
final List<dynamic> toRemoveRangesThatHaveBeenMerged = <dynamic>[];
|
||||
final List<dynamic> toAddRangesThatHaveBeenMerged = <dynamic>[];
|
||||
for (int i = 0; i < overlappingTriples.length; i++) {
|
||||
bool didOverlap = false;
|
||||
List<dynamic> tripleA = overlappingTriples[i];
|
||||
if (toRemoveRangesThatHaveBeenMerged.contains(tripleA)) continue;
|
||||
for (int j = i + 1; j < overlappingTriples.length; j++) {
|
||||
final List<dynamic> tripleB = overlappingTriples[j];
|
||||
if (math.max(tripleA[0] as int, tripleB[0] as int)
|
||||
<= math.min(tripleB[1] as int, tripleB[1] as int)
|
||||
<= math.min(tripleA[1] as int, tripleB[1] as int)
|
||||
&& tripleA[2] == tripleB[2]) {
|
||||
toRemoveRangesThatHaveBeenMerged.addAll(<dynamic>[tripleA, tripleB]);
|
||||
tripleA = <dynamic>[
|
||||
@@ -616,10 +617,11 @@ class ReplacementTextEditingController extends TextEditingController {
|
||||
math.max(tripleA[1] as int, tripleB[1] as int),
|
||||
tripleA[2],
|
||||
];
|
||||
didOverlap = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (i != overlappingTriples.length - 1
|
||||
if (didOverlap
|
||||
&& !toAddRangesThatHaveBeenMerged.contains(tripleA)
|
||||
&& !toRemoveRangesThatHaveBeenMerged.contains(tripleA)) {
|
||||
toAddRangesThatHaveBeenMerged.add(tripleA);
|
||||
|
||||
Reference in New Issue
Block a user