Skip to content

Commit

Permalink
Switching back to start end as it made no difference
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Aug 27, 2024
1 parent 0d037ef commit c620feb
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ public SyntaxHighlighterBase configure(@Nullable final Paint paint) {
* A class representing any span
*/
public static class SpanGroup implements Comparable<SpanGroup> {
int start, length;
int start, end;
final Object span;
final boolean isStatic;

SpanGroup(Object o, int s, int l) {
SpanGroup(Object o, int s, int e) {
span = o;
start = s;
length = l;
end = e;
isStatic = o instanceof UpdateLayout;
}

Expand Down Expand Up @@ -226,11 +226,11 @@ public SyntaxHighlighterBase fixup(final int start, final int before, final int
}

/**
* Adjust all currently computed spans. Use to adjust spans after text edited.
* Adjust all currently computed spans so that the spans are still valid after text changes
* We internally buffer / batch these fixes for increased performance
*
* @param after Apply to spans with region starting after 'after'
* @param delta Apply to
* @param delta How much to shift each span
* @return this
*/
public SyntaxHighlighterBase fixup(final int after, final int delta) {
Expand Down Expand Up @@ -315,10 +315,9 @@ public SyntaxHighlighterBase applyDynamic(final int[] range) {
break;
}

final int end = group.start + group.length;
final boolean valid = group.start >= 0 && end > range[0] && end <= length;
final boolean valid = group.start >= 0 && group.end > range[0] && group.end <= length;
if (valid && !_appliedDynamic.contains(i)) {
_spannable.setSpan(group.span, group.start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
_spannable.setSpan(group.span, group.start, group.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
_appliedDynamic.add(i);
}
}
Expand All @@ -335,7 +334,7 @@ public SyntaxHighlighterBase applyStatic() {

for (final SpanGroup group : _groups) {
if (group.isStatic) {
_spannable.setSpan(group.span, group.start, group.start + group.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
_spannable.setSpan(group.span, group.start, group.start + group.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}

Expand Down Expand Up @@ -409,7 +408,7 @@ public final SyntaxHighlighterBase compute() {

protected final void addSpanGroup(final Object span, final int start, final int end) {
if (end > start && span != null) {
_groupBuffer.add(new SpanGroup(span, start, end - start));
_groupBuffer.add(new SpanGroup(span, start, end));
}
}

Expand Down

0 comments on commit c620feb

Please sign in to comment.