Skip to content

Commit

Permalink
Skip 0 length ranges when splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Dec 18, 2024
1 parent 62d2771 commit 8b86916
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import androidx.annotation.NonNull;

import com.facebook.systrace.Systrace;

import java.util.ArrayList;
import java.util.List;

public class RangeSplitter {
public static ArrayList<MarkdownRange> splitRangesOnEmojis(@NonNull List<MarkdownRange> markdownRanges, @NonNull String type) {
Systrace.beginSection(0, "splitRangesOnEmojis");
ArrayList<MarkdownRange> emojiRanges = new ArrayList<>();
ArrayList<MarkdownRange> oldRanges = new ArrayList<>(markdownRanges);
ArrayList<MarkdownRange> newRanges = new ArrayList<>();
Expand Down Expand Up @@ -41,13 +44,16 @@ public static ArrayList<MarkdownRange> splitRangesOnEmojis(@NonNull List<Markdow
MarkdownRange newRange = new MarkdownRange(currentRange.getType(), currentStart, emojiStart - currentStart, currentRange.getDepth());
currentRange = new MarkdownRange(currentRange.getType(), emojiEnd, currentEnd - emojiEnd, currentRange.getDepth());

newRanges.add(newRange);
if (newRange.getLength() > 0) {
newRanges.add(newRange);
}
}
j += 1;
}
newRanges.add(currentRange);
i += 1;
}
Systrace.endSection(0);
return newRanges;
}
}

0 comments on commit 8b86916

Please sign in to comment.